Answer the question
In order to leave comments, you need to log in
What is the difference between ModelTransformer and ViewTransformer?
Hello. Actually, what is the difference between these two transformers?
Example: add the test field to the form:
$builder->add('test', TextType::class, [
'mapped' => false,
])
public function transform($value)
{
return $value;
}
public function reverseTransform($value)
{
if (!$value) {
return null;
}
return $this->entityManager
->getRepository(Test::class)
->find($value);
}
Answer the question
In order to leave comments, you need to log in
Information about this is in the documentation .
In short, the difference lies in how the result of the transformation will be used.
ModelTransformer
converts form element data to be stored in the model or retrieved data from the model into a form,ViewTransformer
converts form element data for rendering to a view or getting data from a request to a form,Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question