I have created a custom module and in the admin New/Edit form I added the image field but when I submit the form with uploading image, it won't show the image in save controller.
I used to add below code to add image field in admin from:
$fieldset->addField(
'image',
'image',
array(
'label' => __('Image'),
'name' => 'image',
'class' =>'admin__control-image',
)
);
also in my form, I added the multipart form data as below:
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post' , 'enctype' => 'multipart/form-data']]
);
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
How to get rid of this issue?
Thanks in advance!