P
P
Pavel Novikov2018-06-20 11:07:48
symfony
Pavel Novikov, 2018-06-20 11:07:48

How to change field type in Symfony child form?

I have a form that extends another form and I need to take a field from the parent form and change its type. What needs to be supplied as arguments to the setType method, the code is given below
$builder->get('locationSelector')->setType();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2018-06-20
@BoShurik

Just add a new field with the same name:

$builder->add('locationSelector', NewType::class, [
    // ...
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question