P
P
postgresdev2019-09-10 14:42:46
symfony
postgresdev, 2019-09-10 14:42:46

Symfony duplicates the radio inputs at the end of the form on its own if you specify required=false on the form, what's the reason?

An example of what it looks like:
5d778be44d919911451094.png
Form code:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('integratedPunchout', CheckboxType::class, [
            'required' => false,
            'empty_data' => false,
        ])->add('eprocurementSystemUsed', ChoiceType::class, [
            'choices' => [
                'Ariba' => AccountSetting::EPROCURMENT_SYSYTEM_ARIBA,
                'Proactis' => AccountSetting::EPROCURMENT_SYSYTEM_PROACTIS,
                'Coupa' => AccountSetting::EPROCURMENT_SYSYTEM_COUPA,
            ],
            'expanded' => true,
            'multiple' => false,
            'required' => false,
            'empty_data' => null,
        ])->add('eprocurementLevel', ChoiceType::class, [
            'choices' => [
                'PDF Orders' => AccountSetting::EPROCURMENT_LEVEL_PDF,
                'cXML Orders' => AccountSetting::EPROCURMENT_LEVEL_CXML,
                'Full Integration' => AccountSetting::EPROCURMENT_LEVEL_FULL_INTEGRATION,
            ],
            'expanded' => true,
            'multiple' => false,
            'required' => false,
            'empty_data' => null,
        ])->add('unspsc', CheckboxType::class, [
            'required' => false,
            'empty_data' => false,
        ]);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fishernet, 2019-09-18
@Fishernet

If everything works and exactly duplicates, then try this, instead of the usual closing of the form:

{{ form_widget(form._token) }}
{{ form_end(form, {'render_rest': false}) }}

In general, I can’t imagine in what situation radio is not required ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question