0

I am using Magento Version 2.3.4-p2.

I need to hide sku attribute if another status attribute is enabled and vice versa in cart price rule form backend.

I need to change in xml file. Kindly check the below code and confirm.

app/code/Namespace/Promotions/view/adminhtml/ui_component/sales_rule_form.xml

 <fieldset name="rule_information" sortOrder="10">
    
            <field name="sku" formElement="input">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="source" xsi:type="string">sku</item>
                    </item>
                </argument>
                <settings>
                    <dataType>text</dataType>
                    <label translate="true">Literature SKU</label>
                    <visible>true</visible>
                    <dataScope>sku</dataScope>
                </settings>
            </field>
    
            <field name="status" formElement="checkbox">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="source" xsi:type="string">status</item>
                        <item name="default" xsi:type="number">0</item>
                    </item>
                </argument>
                <settings>
                    <dataType>boolean</dataType>
                    <label translate="true">Status</label>       
                </settings>
                <formElements>
                    <checkbox>
                        <settings>
                            <valueMap>
                                <map name="false" xsi:type="number">0</map>
                                <map name="true" xsi:type="number">1</map>
                            </valueMap>
                            <prefer>toggle</prefer>
                        </settings>
                    </checkbox>
                </formElements>
            </field>       
        </fieldset>

if anyone have any idea, please let me know.

1 Answer 1

0

try this :

    
            <field name="sku" formElement="input">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="source" xsi:type="string">sku</item>
                    </item>
                </argument>
                <settings>
                    <dataType>text</dataType>
                    <label translate="true">Literature SKU</label>
                    <visible>true</visible>
                    <dataScope>sku</dataScope>
                </settings>
            </field>
    
            <field name="status" formElement="checkbox">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="source" xsi:type="string">status</item>
                        <item name="default" xsi:type="number">0</item>
                    </item>
                </argument>
                <settings>
                    <dataType>boolean</dataType>
                    <label translate="true">Status</label>
                   <exports>
                        <link name="checked">ns = ${ $.ns }, index = sku :visible</link>
                    </exports>       
                </settings>
                <formElements>
                    <checkbox>
                        <settings>
                            <valueMap>
                                <map name="false" xsi:type="number">0</map>
                                <map name="true" xsi:type="number">1</map>
                            </valueMap>
                            <prefer>toggle</prefer>
                        </settings>
                    </checkbox>
                </formElements>
            </field>       
        </fieldset>
1
  • Thanks it worked :)
    – Prince
    Commented Nov 3, 2020 at 10:39

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.