浏览文章

文章信息

Magento2 使用xml UI布局添加动态字段dynamicRows使用 14255

示例:

<fieldset name="tab">
        <settings>
            <label translate="true">属性选项卡</label>
        </settings>
        <dynamicRows name="tabs">
            <settings>
                <addButtonLabel translate="true">添加新选项</addButtonLabel>
                <dndConfig>
                    <param name="enabled" xsi:type="boolean">true</param>
                    <param name="draggableElementClass" xsi:type="string">_dragged</param>
                    <param name="tableClass" xsi:type="string">table.admin__dynamic-rows</param>
                </dndConfig>
            </settings>
            <container name="record" component="Magento_Ui/js/dynamic-rows/record">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="isTemplate" xsi:type="boolean">true</item>
                        <item name="is_collection" xsi:type="boolean">true</item>
                        <item name="componentType" xsi:type="string">container</item>
                    </item>
                </argument>
                <field name="tab_id" formElement="input">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                            <item name="disable" xsi:type="boolean">true</item>
                        </item>
                    </argument>
                    <settings>
                        <validation>
                            <rule name="required-entry" xsi:type="boolean">false</rule>
                        </validation>
                        <dataType>text</dataType>
                        <label>Tab ID</label>
                        <disabled>1</disabled>
                    </settings>
                </field>
                <field name="tab_code" formElement="input">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                            <item name="visibility" xsi:type="boolean">true</item>
                        </item>
                    </argument>
                    <settings>
                        <validation>
                            <rule name="required-entry" xsi:type="boolean">true</rule>
                        </validation>
                        <dataType>text</dataType>
                        <label>Tab Code</label>
                    </settings>
                </field>
                <field name="tab_name" formElement="input">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                        </item>
                    </argument>
                    <settings>
                        <validation>
                            <rule name="required-entry" xsi:type="boolean">true</rule>
                        </validation>
                        <dataType>text</dataType>
                        <label>Tab Name</label>
                    </settings>
                </field>
                <field name="is_active" formElement="select">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="fit" xsi:type="boolean">false</item>
                        </item>
                    </argument>
                    <settings>
                        <validation>
                            <rule name="required-entry" xsi:type="boolean">true</rule>
                        </validation>
                        <dataType>text</dataType>
                        <label>Is Active</label>
                    </settings>
                    <formElements>
                        <select>
                            <settings>
                                <options class="Magento\Config\Model\Config\Source\Enabledisable"/>
                            </settings>
                        </select>
                    </formElements>
                </field>
            </container>
        </dynamicRows>
    </fieldset>


原创