Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With Symfony2 how can I get the form validator to require at least one of a set of fields?

Tags:

symfony

I have a from where you can fill in any combination of your home, cell, or work phone numbers.

How can I get the validator to require that at least one is filled in without requiring any of the fields individually?

like image 251
Asa Ayers Avatar asked Mar 23 '12 17:03

Asa Ayers


1 Answers

You have at least two options:

  • Create a custom validation constraint,
  • Or use the callback constraint.
like image 76
Elnur Abdurrakhimov Avatar answered Sep 30 '22 08:09

Elnur Abdurrakhimov