I am submitting a form with a lot of fields and trying to validate it with handleRequest($request)
as it is shown in the Symfony documentation.
My entity is very big and has a lot of relations with other entities.
handleRequest($request)
is validating each form field submitted and checking for errors.
The problem found is while submitting an id of a related entity of my main entity (in example a person of an office), handleRequest
will internally get all objects of the related entity (the full table of the related entity, all persons) and hydrating them as objects.
I think it should just check if the submitted id exists in the other table, get that related entity object and check it for errors (instead of getting all the related table).
If you check and debug the source code of Symfony2 handleRequest
, you may easily spot the same problem at this lines:
Form/Form.php
// Normalize data to unified representation
$normData = $this->viewToNorm($viewData);
$value = $transformers[$i]->reverseTransform($value);
How can I still validate the form without dealing with this issue which makes it insanely slow to validate a form with handleRequest($request)
?
If I don't use handleRequest to validate it, which automatically add the errors to my form for each field, how could I manually validate each field and later add the errors to my form for each field and show them in the next view?