[Zope3-Users] Formlib - handleSubmit, custom validator on action

Darryl Cousins darryl at darrylcousins.net.nz
Thu Mar 29 01:18:55 EDT 2007


Hi,

I'm curious about custom validators on a form action:

@action('Edit', validator=my_validator)
def edit(self, **data):
	...

The validator is called from 'update' method of the form:
formlib/form.py line 736:

  errors, action = handleSubmit(self.actions, data, self.validate)

but the line previous says

  data = {}

So my validator always receives an empty dictionary to validate.

The validator is called with arguments 'form, action, data' and should
return a list of errors (if any). Do I need then to use the form object
to retrieve the submitted values? If so, why is 'data' passed at all if
it is always an empty dictionary?

Curious.
Regards,
Darryl

PS I know and have used @invariant but I'm generating the schema
formfields instead of using an interface (where I would normally place
the invariant).



More information about the Zope3-users mailing list