Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.


Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

More than one Validator?


2 Posts   957 Views


12 October 2008 at 9:27am (Last edited: 13 October 2008 8:59am), Community Member, 501 Posts

I was wondering how I can specify more than one validator for a form?

Suppose I want to have RequiredFields, plus another validator of my own, how can I add this to a form?

As far as I can see, you can only pass one validator to the Form constructor, right? It won't accept an array of Validator objects I suppose... thus making this impossible?

Also, I was wondering what the point is of returning 'true' or 'false' in the php() method of Validator/RequiredFields? - it seems to me the only thing having a result is throwing a validationError() ?

And thirdly - is it possible to add a field to a form after the form has been created? - as on validation? (so when the failed form is returned?) In other words, change the form/add a field from within the validator? I don't think so but I might be wrong... I think I'll need to change/decorate the 'beforeProcessing' of Form somehow, or have a RedirectBack that lets me add a field.


13 October 2008 at 9:55am Community Member, 501 Posts

Nevermind, think I've found it... more or less.