Back to index

plone3  3.1.7
Functions
plone.app.form.validators Namespace Reference

Functions

def update_only_validator
def null_validator

Function Documentation

def plone.app.form.validators.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"),
             validator=null_validator,
             name=u'cancel')

Definition at line 10 of file validators.py.

00010 
00011 def null_validator(*args, **kwargs):
00012     """A validator that doesn't validate anything.
00013     
00014     This is somewhat lame, but if you have a "Cancel" type button that
00015     won't want to validate the form, you need something like this.
00016 
00017     @form.action(_(u"label_cancel", default=u"Cancel"),
00018                  validator=null_validator,
00019                  name=u'cancel')
00020     """
00021     return ()
Only validate an action when updating a form.

This allows you to create an action without having formlib render a
button for it.

Definition at line 1 of file validators.py.

00001 def update_only_validator(form, action):
00002     """Only validate an action when updating a form.
00003 
00004     This allows you to create an action without having formlib render a
00005     button for it.
00006     """ 
00007     return "form_result" not in form.__dict__
00008 
00009