]> git.decadent.org.uk Git - maypole.git/blob - ex/fancy_example/templates/factory/addnew
tested and it seems to work
[maypole.git] / ex / fancy_example / templates / factory / addnew
1 [%#
2
3 =head1 addnew
4
5 This is the interface to adding a new instance of an object. (or a new
6 row in the database, if you want to look at it that way) It displays a
7 form containing a list of HTML components for each of the columns in the
8 table.
9
10 =cut
11
12 #%]
13
14 <div id="addnew">
15 <form method="post" action="[% base %]/[% classmetadata.table %]/do_edit/">
16     <fieldset>
17 <legend>Add a new [% classmetadata.moniker %]</legend>
18     [% FOR col = classmetadata.columns %]
19         [% NEXT IF col == "id" %]
20             <label><span class="field">[% classmetadata.colnames.$col %]</span>
21             [% 
22             SET elem = classmetadata.cgi.$col.clone;
23             IF request.action == 'do_edit';
24                 IF elem.tag == "textarea";
25                     elem = elem.push_content(request.param(col));
26                 ELSE;
27                     elem.attr("value", request.param(col));
28                 END;
29             END;
30             elem.as_XML; %]
31             </label>
32         [% IF errors.$col %]
33            <span class="error">[% errors.$col | html  %]</span>
34         [% END %]
35
36     [% END; %]
37     <input type="submit" name="create" value="create" />
38     <input type="hidden" name="__form_id" value="[% request.make_random_id %]" />
39 </fieldset>
40 </form>
41 </div>