cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Product Chooser Widget with UI Component Admin Form

How to use Product Chooser Widget with UI Component Admin Form

I want to have a field in my UI Component form and a "Select Product..." Button where I can choose a product and it gets inserted into the input so I can save it to my database.
Similar to the "Catalog Product Link" Widget.

GDsyW.png

Started by adding this to my ui_component form.xml but without desired result:

<fieldset name="assign_products" sortOrder="40">
    <settings>
        <collapsible>true</collapsible>
        <label translate="true">Products</label>
    </settings>
    <container name="assign_products_container" sortOrder="160">
        <htmlContent name="html_content">
            <block name="my_assigned_products" class="Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser">
                <arguments>
                    <argument name="button" xsi:type="array">
                        <item name="open" xsi:type="string" translate="true">Select Product...</item>
                    </argument>
                </arguments>
            </block>
        </htmlContent>
    </container>
</fieldset>

Any tips?