0

I have a module that is creating dynamically generated admin fields with Image upload it's not saving and showing in the admin panel.

Is their any way it can be implemented ? enter image description here

I have added the image field in dynamic rows like below

$this->addColumn(
    'image',
    [
    'label' => __('Image'),
    'renderer' => $this->getImageRenderer()
]);
private function getImageRenderer()
{
    if (!$this->imageRenderer) {
        $this->imageRenderer = $this->getLayout()->createBlock(
            \Vendor\Module\Block\Adminhtml\Blocks\Edit\Tab\ImageRenderer::class,
            '',
            ['data' => ['is_render_to_js_template' => true]]
        );
    }
    return $this->imageRenderer;
}

ImageRenderer class

<?php

namespace Vendor\Module\Block\Adminhtml\Blocks\Edit\Tab;

class ImageRenderer extends \Magento\Framework\View\Element\AbstractBlock
{
    /**
     * {@inheritdoc}
     */
    protected function _toHtml()
    {
        $html = '<input type="file" name="' . $this->getInputName() . '" id="' . $this->getInputId() . '" ';
        $html .= '<image name="' . $this->getInputName() . '" id="' . $this->getInputId() . '" />';
        return $html;
    }
}
1
  • any thoughts on this?
    – user104369
    Apr 16, 2022 at 14:32

1 Answer 1

1

Check this

https://magento-qa.com/how-to-create-a-dynamic-generated-admin-fields-with-image-upload

I hope it will help you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.