[Zope3-Users] Multiple actions per button in formlib forms?
Bjorn Tillenius
bjorn.tillenius at gmail.com
Fri Sep 15 02:58:28 EDT 2006
On Thu, Sep 14, 2006 at 02:34:59PM +0200, Stefan Fink wrote:
> Hi list,
>
> how is it possible to add multiple actions per button to formlib forms?
> Actually I'm trying to create a button which:
> - applies all changes made in the form
> - takes the user back to the container view
>
>
> class GeneralEditForm(formlib.form.EditForm):
>
> ...
>
> # this does not work
> @formlib.form.action(u'Apply&Close')
> def handle_applyAndClose(self, action, data):
> """ apply form changes and close form."""
> self.handle_edit_action(action, data)
You didn't include how you define handle_edit_action, but I assume you
use @formlib.form.action here as well:
@formlib.form.action(u'Edit')
def handle_edit_action(self, action, data):
...
What this code does is to create a new Action object, having the
handle_edit_action method as its success method. This action will be
added to self.actions, but more importantly, this action will also be
assigned to self.handle_edit_action. So in your handle_applyAndClose
method above, self.handle_edit_action isn't a method, it's an Action
object. (c.f the way @property works). So in order to call your edit
action you need to do:
self.handle_edit_action.sucess(data)
Regards,
Bjorn
More information about the Zope3-users
mailing list