浏览文章

文章信息

Magento2 设置UI组件字段默认值|Magento2 set default value for UI component 12658

关键

<argument name="data" xsi:type="array">
   <item name="config" xsi:type="array">
      <item name="default" xsi:type="string">1</item>
   </item>
</argument>

示例:

 <field name="is_active" formElement="checkbox">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="default" xsi:type="string">1</item>
                </item>
            </argument>
            <settings>
                <label translate="true">启用状态</label>
                <tooltip>
                    <description translate="true">启用则生效,不启用则不生效!</description>
                </tooltip>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
            </settings>
            <formElements>
                <checkbox>
                    <settings>
                        <prefer>toggle</prefer>
                        <valueMap>
                            <map name="false" xsi:type="string">0</map>
                            <map name="true" xsi:type="string">1</map>
                        </valueMap>
                    </settings>
                </checkbox>
            </formElements>
        </field>


原创