How to add conditional validation in symfony 2.1 forms
Possible duplicate:
Assert property dependent on another property symfony 2
I have an object as shown below:
class Items {
/*
* @Assert\NotBlank(message="Title cannot be blank")
*/
private $title;
/*
* @Assert\Range(
* min = "0.1",
* minMessage = "Price should be a positive number",
* invalidMessage = "Price should be in number."
* )
*/
private $price;
private $currency;
}
I am using symfony 2.1 with a form of ItemType class.
I want to add validation constraints to $ currency only if the price is valid. How can i do this? I want to do this both from the controller and if possible in the form class so that it is useful to others as well, as well
+3
source to share
1 answer
I didn't understand this question. My bad one.
I think this is what you are looking for: http://symfony.com/legacy/doc/forms/1_2/en/02-form-validation
-4
source to share