Reputation: 399
I´d like to use Symfony 2 Validation Component to validate my forms without using form component as I prefer to create my own HTML forms manually. How can I do to bind the data from my manual form to an entity so that I can validate that entity in the controller?
Upvotes: 0
Views: 1072
Reputation: 44831
Just go through the $request->request
parameter bag and use the setters of your model to set the data. Then you can use the validator
service to validate the entity:
$constraintViolationList = $this->get('validator')->validate($entity);
If $constraintViolationList
is not empty, the entity is not valid.
BTW, I believe that the Symfony form component is arguably the greatest part of the framework. I suggest you reconsider your position about it.
Upvotes: 3