0

I want create a widget.xml like that:

<parameter name="attribute_options" xsi:type="MT\Widget\Block\Adminhtml\Widget\Attribute\Option"  visible="true">
            <label translate="true">Attribute Options</label>
            <description translate="true">Select attribute options to show</description>
        </parameter>

So, could I create a new parameter type like xsi:type="MT\Widget\Block\Adminhtml\Widget\Attribute\Option" ? If no, how can expand new atomic type?

0

You can't create new atomic types. In the XML schema definition file: /vendor/magento/module-widget/etc/widget.xsd are defined all allowed types.

For you case I guess that you want to add parameter with type select and populate with custom options. Then you should set attribute xsi:type to "select" and another "source_model" attribute with value MT\Widget\Block\Adminhtml\Widget\Attribute\Option like this:

<parameter name="attribute_options" xsi:type="select" source_model="MT\Widget\Block\Adminhtml\Widget\Attribute\Option" visible="true">
    <label translate="true">Attribute Options</label>
    <description translate="true">Select attribute options to show</description>
</parameter>
0

You can define block type and then insert block like this:

<parameter name="id_path" xsi:type="block" visible="true" required="true" sort_order="10">
    <label translate="true">Product</label>
    <block class="Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser">
        <data>
            <item name="button" xsi:type="array">
                <item name="open" xsi:type="string" translate="true">Select Product...</item>
            </item>
        </data>
    </block>
</parameter>

Check file app/code/Magento/Catalog/etc/widget.xml for example code.

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.