I have created a custom module which have dynamic rows. I have added Image field there with dropdown and some other text field. But when I am trying to save input type file is not getting in post request but when i changed to text it is working fine.
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender() {
$this->addColumn(
'image_thumb', [
'label' => __('Thumbnail'),
'renderer' => $this->getImageColumnRenderer()
]
);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
/**
* Image Column Renderer
*
* @param string $columnName
* @return string
* @throws \Exception
*/
protected function getImageColumnRenderer() {
if (!$this->_imageRenderer) {
$this->_imageRenderer = $this->getLayout()->createBlock(
\Namespace\Module\Block\Adminhtml\Form\Field\Thumbnail::class, '', ['data' => ['is_render_to_js_template' => true]]
);
}
return $this->_imageRenderer;
}
Namespace\Module\Block\Adminhtml\Form\Field\Thumbnail.php
namespace Namespace\Module\Block\Adminhtml\Form\Field;
/**
* Class Thumbnail
*/
class Thumbnail extends \Magento\Framework\View\Element\AbstractBlock
{
/**
* @return image html
*/
protected function _toHtml()
{
$html = '<input type="file" name="' . $this->getInputName() . '" id="' . $this->getInputId() . '" />';
return $html;
}
}
If you guys have any Idea please share
Any help will be appreciated