[Grok-dev] Separating action buttons in the layout
sebastian at urbantalk.se
Thu Jul 5 10:46:58 EDT 2007
I found this in a design document for formlib. Is this doable in
Grok? Grouping actions is obviously very useful in UI design... :)
Multiple button groups
Multiple button groups can be accomplished many ways, but the way
that reuses the most code is the following:
>>> import zope.cachedescriptors.property
>>> class MyForm(form.Form):
... form_fields = form.Fields(IOrder)
... primary_actions = form.Actions()
... secondary_actions = form.Actions()
... def actions(self):
... return list(self.primary_actions) + list
... @form.action(u'Edit', primary_actions)
... def handle_edit_action(self, action, data):
... if form.applyChanges(self.context, self.form_fields,
... self.status = 'Object updated'
... self.status = 'No changes'
... @form.action(u'Submit for review...', secondary_actions)
... def handle_review_action(self, action, data):
... print "do something here"
The template then can render the button groups separately--something
following, for instance:
<input tal:repeat="action view/primary_actions"
<input tal:repeat="action view/secondary_actions"
But the form machinery can still find the correct button. # TODO: demo
27 jun 2007 kl. 22.19 skrev Sebastian Ware:
> Grok automatically inserts all the action buttons in the same span.
> However, I would like to separate the actions, and possibly render
> them differently depending on what kind of action it is (edit
> actions vs. workflow actions).
> Is this possible? How would I do it?
> Mvh Sebastian
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev