#StackBounty: #magento2 #dynamic-rows #magentomodule #magento-admin Magento 2 Dynamic rows with upload image in admin module not in sys…

Bounty: 50

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(
                NamespaceModuleBlockAdminhtmlFormFieldThumbnail::class, '', ['data' => ['is_render_to_js_template' => true]]
        );
    }
    return $this->_imageRenderer;
}

NamespaceModuleBlockAdminhtmlFormFieldThumbnail.php

namespace NamespaceModuleBlockAdminhtmlFormField;

/**
 * Class Thumbnail
 */
class Thumbnail extends MagentoFrameworkViewElementAbstractBlock
{
    /**
     * @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


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.