S
S
symnoob2022-02-08 11:41:48
symfony
symnoob, 2022-02-08 11:41:48

EntityType Field how to get only string after form submit?

Hello everyone,
I'm trying to get a string after submitting the form, but only an object of the class comes when using the EntityType Field
, can anyone help?

->add('nds', EntityType::class, [
                'class' => Nds::class,
                'choice_label' => function ($nds) {
                    return $nds->getDesc();
                },
                'label' => false,
                'empty_data' => null,
                'placeholder' => 'NDS'
            ])


That is, after the form has been submitted, the value "nds / nds" from the form should appear as a string, but the object comes ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2022-02-08
@symnoob

https://symfony.com/doc/current/form/data_transform...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question