Hello list,

I keep hearing about the wonders of formlib, so I've been trying to
migrate one of my zcml browser:editform generated forms to formlib. 
Once I figured out how to "select(...)" fields to avoid problems with
the "__parent__" field on my interface, this worked acceptably.

After edit changes are applied, I want to redirect the user to another
page (ultimately, to the page from which they came).  Before I did
this with a "changed" method on my edit form class, but this did not
work when I switched to formlib.

Below you can see my approach.  From within my "changed" method, I
manually call "handle_edit_action" which gives a TypeError because the
'Action' object is not callable.  Unfortunately, without
"handle_edit_action", the object never gets changed upon "apply".

** What is the best way to use a formlib EditForm to redirect a user
after applying changes without fully cloning a "handle_edit_action"
method? **

Many thanks,

from zope.formlib import form
from zope.formlib.form import action, haveInputWidgets

class PitcherEditForm(form.EditForm):

    form_fields = form.Fields(interfaces.IPitcher).select('Last',
'First', 'ERA')

    @action(_("Apply"), condition=haveInputWidgets)
    def changed(self, action, data):
        #TypeError: 'Action' object is not callable
        self.handle_edit_action(action, data)
Zope3-users mailing list

Reply via email to