How to set default value for tex

2018-05-20  本文已影响10人  葡萄月令

How to set default value for text and select field in admin new UI form in magento 2

You need to add below code:

<item name="default" xsi:type="string">1</item>

Example:

<field name="price">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string" translate="true">Price</item>
            <item name="visible" xsi:type="boolean">true</item>
            <item name="dataType" xsi:type="string">text</item>
            <item name="formElement" xsi:type="string">input</item>
            <item name="source" xsi:type="string">product_information</item>
            <item name="dataScope" xsi:type="string">price</item>
            <item name="default" xsi:type="string">0</item>
            <item name="validation" xsi:type="array">
                <item name="required-entry" xsi:type="boolean">true</item>
                <item name="validate-number" xsi:type="boolean">true</item>
            </item>
        </item>
    </argument>
</field>

Tony's blog image

More Information, Please Subscribe My Wechat Public Platform Or View My Blog : https://www.abmbio.xin

20180117_81914.jpg
上一篇下一篇

猜你喜欢

热点阅读