Currently I have following code in symfony 2 and I want to upgrade it to symfony 3. I get this deprecation warning to use form_start instead of form_enctype. How can I change the following code with form_start?
View:
<form method="post" {{ form_enctype(decryptionForm) }}>
                                {{ form_widget(decryptionForm) }}
                                {{ submit_widget }}
                            </form>
Controller
$form = new DecryptionForm();
        $this->setContext(array(
            'decryptionForm' => $form->createView()
        ));
Form
$builder = $this->getFormBuilder();
        $form = $builder
            ->add(self::FORM_KEY_SAMPLECASE, 'hidden', array())
            ->add(self::FORM_KEY_DECRKEYFILE, 'file', array(
                'constraints' => array(new NotBlank()),
                'label' => "private_key"
            ))
            ->add("Submit", 'submit')
            ->getForm();
                You can replace
<form method="post" {{ form_enctype(decryptionForm) }}>
by
{{ form_start(decryptionForm) }}
and
</form>
by
{{ form_end(decryptionForm) }}
                        As Alvin mentioned replace form opening and closing to symfony provided functions:
{{ form_start(decryptionForm) }} and {{ form_end(decryptionForm) }}. Now Symfony handles enctype by default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With