[Grok-dev] Separating action buttons in the layout

Sebastian Ware 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... :)
http://svn.zope.org/zope.formlib/trunk/src/zope/formlib/form.txt? 
rev=75131&view=markup

Multiple button groups
----------------------

Multiple button groups can be accomplished many ways, but the way  
we've found
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()
     ...     @zope.cachedescriptors.property.Lazy
     ...     def actions(self):
     ...         return list(self.primary_actions) + list 
(self.secondary_actions)
     ...     @form.action(u'Edit', primary_actions)
     ...     def handle_edit_action(self, action, data):
     ...         if form.applyChanges(self.context, self.form_fields,  
data):
     ...             self.status = 'Object updated'
     ...         else:
     ...             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  
like the
following, for instance:

     <input tal:repeat="action view/primary_actions"
        tal:replace="structure action/render"
        />

and

     <input tal:repeat="action view/secondary_actions"
        tal:replace="structure action/render"
        />

But the form machinery can still find the correct button. # TODO: demo

Mvh Sebastian

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
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list