I have create online module by "https://code.vky.co.in/magento-2-module-creator/" this site. Now i want to add extra custom filed of multiple select dropdown. Dropdown filed showing lavel is product name and value is product id. How to get product name and id in dropdown with store value in database How to do? please help enter image description here

1 Answer 1


You can achive via renderer. do something like below example

You can add Renderer in your Form.php file like this.


$field = $fieldset->addField(
        'name' => 'club_color',
        'label' => __('Color'),
        'title' => __('Color')

And now you need to create your renderer file here in your module.


Content for this file is..

namespace Vendor\Module\Block\Adminhtml\Renderer;

class Color extends \Magento\Framework\Data\Form\Element\AbstractElement
    public function getElementHtml()
        $html = parent::getElementHtml();
        $value = $this->getValue();
        $html .= '<script type="text/javascript">
        require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
            $(document).ready(function () {
                var $el = $("#' . $this->getHtmlId() . '");
                $el.css("backgroundColor", "'. $value .'");

                // Attach the color picker
                    color: "'. $value .'",
                    onChange: function (hsb, hex, rgb) {
                        $el.css("backgroundColor", "#" + hex).val("#" + hex);
        return $html;

Hope this will help you!

Your Answer

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

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