I have added a new field in the Cart Price Rule form as below. I have saved the value in the table as a new column

 <?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="rule_information" sortOrder="10">
        <field name="store_ids">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</item>
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">int</item>
                    <item name="label" xsi:type="string" translate="true">Store View Test</item>
                    <item name="formElement" xsi:type="string">multiselect</item>
                    <item name="source" xsi:type="string">sales_rule</item>
                    <item name="dataScope" xsi:type="string">store_ids</item>
                    <item name="default" xsi:type="string">0</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>

enter image description here Now I have to validate this condition in the rule validator. How can I do it?

  • pls add the field screenshot Dec 2, 2022 at 6:24
  • @RohanHapani Updated the screenshot Dec 2, 2022 at 6:28
  • Youjust want to add multi select as required. right? Dec 2, 2022 at 7:13
  • @RohanHapani Yes, I need the selected store ids. Dec 2, 2022 at 8:04

1 Answer 1


You can try with validate tag below new field.

Otherwise, Magento also supports you validate server side through by:

<backend_model>[Name_Company][Name_module]\Model\Config\Backend[Name_Class] Magento 2 already defined some validation classes

  • I have to validate this condition in the rule validator, not in admin form Dec 2, 2022 at 8:06
  • Then try with backend_model, declare a class which is inherited from parent class \Magento\Framework\App\Config\Value. The parent class supports functions such as beforeSave, afterSave, getData. Dec 2, 2022 at 9:01
  • I need to validate the store id condition in FE. Like the customer group Dec 2, 2022 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.