1

I've following code in Form.php

$chooser = $this->_layout->createBlock('\Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser');
        //var_dump(get_class_methods($chooser));

        $configChooser = [
            'button' => [
                'open' => __('Select Products'),
                'type' => '\Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser',
            ]
        ];
        $chooser->setConfig($configChooser)
            ->setFieldsetId($fieldset->getId())
            ->prepareElementHtml($productChooser);

When I click on Select Products button I'm getting the following error

widget.js:683 Uncaught TypeError: Cannot read property 'value' of null
    at getElementValue (widget.js:683)
    at g.choose (widget.js:620)
    at HTMLButtonElement.onclick ((index):303)

any idea what could be wrong? enter image description here

0

I've resolved the issue by myself.

Above code is fine in starting of my form code I've added

$form->setHtmlIdPrefix('xyzplan_');

Due to the above line, Widget.js file was not able to find the value of the element and throwing an error.

So I've removed it and it's now working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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