[Grok-dev] Cancel button in forms

Godefroid Chapelle gotcha at bubblenet.be
Mon May 5 07:41:09 EDT 2008

Hi all,

I supposed I must have missed the simple way to have a working cancel 
button with grok forms.

In case this simple way does not exist, I suggest to integrate the 
null_validator (taken from plone)

def null_validator(*args, **kwargs):
     """A validator that doesn't validate anything.

     This is somewhat lame, but if you have a "Cancel" type button that
     won't want to validate the form, you need something like this.

     @form.action(_(u"label_cancel", default=u"Cancel"),
     return ()

class AddWord(grok.AddForm):
     form_fields = grok.AutoFields(Word)

     @grok.action('Cancel', validator=null_validator)
     def cancel(self):

Godefroid Chapelle (aka __gotcha) http://bubblenet.be

More information about the Grok-dev mailing list