[Product-Developers] invariant validator for add form has no context?

zjs2k zjs2k at yahoo.com
Thu Jan 19 01:41:16 UTC 2012

I had the impression that one of the advantages of z3c.form.validators is the
access to context. That's true for SimpleFieldValidator, as demonstrated in
Martin Aspeli's Plone 4 book. So I assumed the same for InvariantsValidator.

But the dexterity add form sets ignoreContext to true. So when the form
trying to get the validator MultiAdapter, the context is set to None (see
z3c.form.field.FieldWidgets.validate). Is this the expected behavior?

What's the best way for full-form validation with access to context? One use
case is using First Name and Last Name fields. I would like to search
catalog to confirm no one has the same first/last name.

Should I override the "save" action handler of dexterity? Or write an event
handler for some form event like ObjectCreatedEvent? No idea about the edit
form event since ObjectModifiedEvent is after object modified.

Any suggestion will be greatly appreciated. 

View this message in context: http://plone.293351.n2.nabble.com/invariant-validator-for-add-form-has-no-context-tp7202472p7202472.html
Sent from the Product Developers mailing list archive at Nabble.com.

More information about the Product-Developers mailing list