Question

I found this list validation rules:

Magento 2 - Form Validation

How to use above list of validation rules in uiForm-uiComponent. Can I add it inside xml <field> tag? or at least how to set required fields?

Was it helpful?

Solution

simple xml code for field required

<item name="validation" xsi:type="array">
    <item name="required-entry" xsi:type="boolean">true</item>
</item>

date validation

<item name="validation" xsi:type="array">
    <item name="validate-date" xsi:type="boolean">true</item>
</item>

validate-email

<item name="validation" xsi:type="array">
    <item name="validate-email" xsi:type="boolean">true</item>
</item>

for example look at

vendor/magento/module-cms/view/adminhtml/ui_component/cms_block_form.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top