I have a $fieldset. What arguments should I give to ->addField method to create an input field, that loads image to $_FILES?

What was done

For now I have an input field.

enter image description here

Created by

                'title' => __('Image'),
                'label' => __('Image'),
                'name' => 'image',
                'note' => 'Allow image type: jpg, jpeg, gif, png',

But the $_FILES is empty, when I checking it in controller execute() method.

Additional information

$fieldset arguments was taken from this example.


Go to file app/code/Vendor/Modulename/Block/Adminhtml/Modulename/Edit/Form.php

there is 'enctype' => 'multipart/form-data'

 $form = $this->_formFactory->create(
            ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post', 'enctype' => 'multipart/form-data']]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.