]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/templates/factory/edit
components now work
[maypole.git] / lib / Maypole / templates / factory / edit
index 6bdad79347cef088c484d66ec30a546387772fb9..14f77be3c172e46eaa3233ee31339bf6d6cd230e 100644 (file)
@@ -11,6 +11,11 @@ form similar to L<addnew> but with the current values filled in.
 [% PROCESS macros %]
 [% INCLUDE header %]
 [% INCLUDE title %]
+
+[% IF request.action == 'edit' %]
+[% INCLUDE navbar %]
+[% END %]
+
 [% IF objects.size %]
 <div id="title">Edit a [% classmetadata.moniker %]</div>
 [% FOR item = objects; %]
@@ -18,7 +23,7 @@ form similar to L<addnew> but with the current values filled in.
 <fieldset>
 <legend>Edit [% item.name %]</legend>
 [% FOR col = classmetadata.columns;
-    NEXT IF col == "id";
+    NEXT IF col == "id" OR col == classmetadata.table _ "_id";
     '<label><span class="field">';
     classmetadata.colnames.$col; ":</span>";
     item.to_field(col).as_XML;
@@ -33,6 +38,35 @@ form similar to L<addnew> but with the current values filled in.
     
     [% END %]
 [% ELSE %]
-[% INCLUDE addnew %]
+
+<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 request.action == 'do_edit';
+                IF elem.tag == "textarea";
+                    elem = elem.push_content(request.param(col));
+                ELSE;
+                    elem.attr("value", request.param(col));
+                END;
+            END;
+            elem.as_XML; %]
+           </label>
+        [% IF errors.$col %]
+           <span class="error">[% errors.$col | html  %]</span>
+        [% END %]
+
+    [% END; %]
+    <input type="submit" name="create" value="create" />
+    <input type="hidden" name="__form_id" value="[% request.make_random_id %]" />
+</fieldset>
+</form>
+</div>
+
 [% END %]
 [% INCLUDE footer %]