T
T
Tarakkolya2014-07-29 23:50:33
symfony
Tarakkolya, 2014-07-29 23:50:33

How to add an entity using select 2 choices?

Please tell me if it is possible to do this: when you enter a string in the field that does not correspond to any entity, an entity with that "name" was created and written to the database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-07-30
@Tarakkolya

what is stopping you from getting this line in the controller and creating this entity yourself?
For example, we get $city = $form->get('city')->getData(); check if there is such a city and create it if not? The DataTransformer is needed to convert one display format to another; it should not be used as an entity record.

S
Sergey, 2014-07-30
Protko @Fesor

You can do anything with shapes in symphony. The easiest option in my opinion is to write your own DataTransformer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question