CappY
CappY

Reputation: 1580

Complex forms with Symfony

is there any way to do complex forms with validation, for example:

Form with radio button with 2 choices A and B and field1,field2 and field3 required IF choice A is selected, and field4, field5 and field6 required IF choice B is selected?

Upvotes: 0

Views: 229

Answers (1)

j-guyon
j-guyon

Reputation: 1832

In order to generate client side control in real time (insert required="required" when necessary), I think the easiest way is to handle it with some Javascript event.

A FormEvent will not be sufficient to manage the user change (if the first radio change from A to B in your example).

For the "real" validation stuff, the best practice is to create your own class validator.

You can learn more about it here :

http://symfony.com/doc/current/cookbook/validation/custom_constraint.html#class-constraint-validator

Best regards.

Upvotes: 2

Related Questions