I have searched a lot on google but I have no idea of how to solve my problem.
I have an Entity EntreeListe
which contains two attributes rayon
and produit
. I would like that the user enter in a text field : Rayon : Produit
.
So, I add two DataTransformer on my textfield produit
$builder->get('produit')
->addModelTransformer(new StringToProduitTransformer($this->manager));
$builder->get('produit')
->addModelTransformer(new StringToRayonTransformer($this->manager));
So that I can transform explode(' : ', $string)[0]
into a Rayon
and explode(' : ', $string)[1]
into a Produit
.
The problem is that, when I submit the form, the parameter passed to reverseTransform
of StringToProduitTransformer
is not a string but a Rayon
because the transformation of StringToRayonTransformer
is already done.
I don't know if I'm clear, so just ask questions. Any suggestions is welcome :).
What I want is to have the string passed to the two reverseTransform... So have multiple DataTransformer for one field.
Or is there another way to do this ? To complete two attributes with one input ?
Thank you very much.