]> git.decadent.org.uk Git - maypole.git/blobdiff - templates/factory/addnew
removed Maypole::Model->description,
[maypole.git] / templates / factory / addnew
index f541e27b995f2a4fb680e7e93100a29b42dda5e3..f530bc99383105fa608e453fe43375ae4c6af986 100644 (file)
@@ -1,14 +1,38 @@
-<h3>Add a new [%classmetadata.moniker%]</h3>
-<FORM METHOD="post" ACTION="[%base%]/[%classmetadata.moniker%]/do_edit/">
-    <INPUT TYPE="hidden" NAME="action" VALUE="create">
-    <INPUT TYPE="hidden" NAME="class" VALUE="[%classmetadata.name%]">
-    <TABLE class="view">
-     [% FOR col = classmetadata.columns;
-        NEXT IF col == "id";
-     %]
-     <TR> <TD class="field"> [% classmetadata.colnames.$col; %] </TD>
-     <TD> [% classmetadata.cgi.$col.as_HTML; %] </TD> </TR>
+[%#
+
+=head1 addnew
+
+This is the interface to adding a new instance of an object. (or a new
+row in the database, if you want to look at it that way) It displays a
+form containing a list of HTML components for each of the columns in the
+table.
+
+=cut
+
+#%]
+
+<div id="addnew">
+<form method="post" action="[% base %]/[% classmetadata.table %]/do_edit/">
+    <fieldset>
+<legend>Add a new [% classmetadata.moniker %]</legend>
+    [% FOR col = classmetadata.columns %]
+        [% NEXT IF col == "id" %]
+            <label><span class="field">[% classmetadata.colnames.$col %]</span>
+            [% 
+            SET elem = classmetadata.cgi.$col.clone;
+            IF elem.tag == "textarea";
+                elem = elem.push_content(request.param(col));
+            ELSE;
+                elem.attr("value", request.param(col));
+            END;
+            elem.as_XML; %]
+           </label>
+        [% IF errors.$col %]
+           <span class="error">[% errors.$col %]</span>
+        [% END %]
+
     [% END; %]
-    </TABLE>
-    <INPUT TYPE="submit" NAME="create" VALUE="create">
-</FORM>
+    <input type="submit" name="create" value="create"/>
+</fieldset>
+</form>
+</div>