I have a custom validator in Symfony2 and I would like to get one of the submited values from my form.
When vardumping the $value from
public function validate($value, Constraint $constraint)
I can see the variable I need, but the result is too big in order to be able to find where is my request parameter placed.
Thank you in advance.
I have found a workaround to this problem:
I created a new field in my entity that does not exists in the database, but exists in the form.
In the validator class, I am accessing all the entity values, and also this new one that I need.
FYI, in order to access all the entity object in the validator, you need to put:
public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.