Re: [Zope3-Users] Cancelling AddForm

2007-03-12 Thread Darryl Cousins
On Mon, 2007-03-12 at 16:18 +0100, Thierry Florac wrote:
>   Hi,
> 
> I have several formlib.form.AddForm subclasses in which I've created a
> custom Action via "@action(...)".
> My problem is that I'd like to be able to launch some of these actions
> (but not all of them, it's "action specific") without executing
> automatic formlib controls (actually, for example, even a simple
> "Cancel" button which should just redirect the browser actually raises
> an exception when required fields are missing).
> 
> Any help ?
> Thanks,
> 
>   Thierry Florac

Hi Thierry,

I implement cancel buttons for formlib like this (probably came from
somewhere but I forget where)::

def always_good(form, action, data):
"""Helper for actions - will always validate - useful for cancel
actions"""
return []

class MyAddForm(form.AddForm):
@form.action(_("Cancel"), validator=always_good)
def handle_cancel(self, action, data):
self.request.response.redirect(self.nextURL())

Hope that helps, regards,
Darryl

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Cancelling AddForm

2007-03-12 Thread Marcin Kołoczek

Thierry Florac wrote:

  Hi,

even a simple "Cancel" button which should just redirect the browser actually 
raises
an exception when required fields are missing).

Any help ?
Thanks,

  Thierry Florac
  
Have You read subject (this list): "formlib vs. cancel button"? Martin 
Aspeli has similar question, and AFAIK there was some clue/solution (at 
least for Cancel button).


Cheers!
/Ramok
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users