Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » More than one Validator?

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

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

Page: 1
Go to End
Author Topic: 939 Views
  • dio5
    Avatar
    Community Member
    501 Posts

    More than one Validator? Link to this post

    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.

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: More than one Validator? Link to this post

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

    939 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.