[Zope-CMF] Formlib implementation for folder contents
Charlie Clark
charlie at begeistert.org
Sun Jun 22 14:29:23 EDT 2008
Hi,
now that I've had a couple of months practice with browser views in
general and formlib in particular and also because I've got a
particular itch to scratch I've started on a formlib version of
folder_contents and I've now got a skeleton version of the form. Well,
I've got the form at least!
What I've done so far:
* a view based on EditForm (haven't quite mastered redirects in
PageForm) but not using setUpEditWidgets - I pass the field values in
as 'data'. Fields are distinguished from each other using the prefix
argument
field = form.FormField(f, n, item.id) # using an interface
self.form_fields += form.FormFields(field)
* turned the buttons into actions - probably the easiest part :-)
* generate fields (Boolean for the checkboxes)
* use a custom template to iterate through the folder items and call
the appropriate widgets. Although this works it's a bit clumsy. This
is the rather stripped-down HTML and I'm anticipating renaming on the
form.
<form class="form" action="." method="post" enctype="multipart/form-
data"
tal:attributes="action request/ACTUAL_URL">
<table>
<tr>
<th>Select</th>
<th>Name</th>
<th>Last Modified</th>
<th>Position</th>
</tr>
<tr tal:repeat="item context/contentValues">
<td tal:content="structure python: view.widgets['%s.select'
%item.id]()">Checkbox</td>
<td tal:content="structure python: view.widgets['%s.name'
%item.id]()"></td>
<td tal:content="item/ModificationDate"></td>
<td tal:content="repeat/item/number"></td>
</tr>
</table>
<div class="buttons">
<tal:loop tal:repeat="action view/actions"
tal:replace="structure action/render" />
</div>
</form>
While I can probably tidy this up to use a method in the view I'm not
convinced it's entirely the right way to do this. But it works!
I'll continue working - the actions themselves should be most
straightforward on this but would appreciate any comments.
Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226
More information about the Zope-CMF
mailing list