Magento2 Disable component using ui_component

11.6k views Asked by At

How can i remove the Magento default form ui component. Such as is in the image which is for the Marketing -> cart price rule -> [select already created rule] -> Schedule New Updates

enter image description here

enter image description here

I want to remove the Rule information, Conditions, Actions, Labels Top Banner, After Product Description Banner, Product Label

As you can see it have some extra ui_components as compare to the default Magento EE. It is because of Amasty_Promo module. So i would like to remove it.

2

There are 2 answers

1
Abbas On BEST ANSWER

For it according to the layout handler create a file in your custom module. In this case it is NameSpace/YourModule/view/adminhtml/ui_component/salesrulestaging_update_form.xml

with the following content:

<argument name="data" xsi:type="array">
  <item name="config" xsi:type="array">
        <item name="componentDisabled" xsi:type="boolean">true</item>
  </item>
</argument>

such as for rule_information it will be like this:

<?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">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="componentDisabled" xsi:type="boolean">true</item>
                </item>
            </argument>
        </fieldset>
    </form>

And make sure <argument> will be the first child of the component.

0
Châu Văn Khánh Nhật On

To Hide field:

    <field name="custom_field">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">Custom Field</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">dataProvider</item>
                <item name="dataScope" xsi:type="string">custom_field</item>
                <item name="componentDisabled" xsi:type="boolean">true</item> <!-- here -->
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>

Just disable (Read Only Field)

    <field name="custom_field">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">Custom Field</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">dataProvider</item>
                <item name="disabled" xsi:type="boolean">true</item> <!-- here -->
                <item name="dataScope" xsi:type="string">custom_field</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>

Hope this will helpful for you!