9

I am developing one custom module in Magento 2.2.2 where I have referenced some internet blog and Magento core extension like cms-page or cms-block. In their grid_listing.xml files wrote code something like below

<columns name="cms_page_columns">
<column name="title">
            <settings>
                <filter>text</filter>
                <editor>
                    <validation>
                        <rule name="required-entry" xsi:type="boolean">true</rule>
                    </validation>
                    <editorType>text</editorType>
                </editor>
                <label translate="true">Title</label>
            </settings>
        </column>
</columns>

And some blog referenced in grid_listing.xml are like below

<columns name="cms_page_columns">
<column name="city">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">City</item>
                    <item name="sortOrder" xsi:type="number">30</item>
                </item>
            </argument>
        </column>
</columns>

So I want to know the difference between <settings> & <argument> node. And which method I have to follow for future development.

11

<settings> was introduced in version 2.2 and it serves only the purpose to have the ui components config files more readable and get autocomplete when defining something.

Basically what you add inside settings can easily be added in arguments in the path data/config.

adding

<argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
        <item name="filter" xsi:type="string">text</item>
    </item>
</argument>

has the same effect as

 <filter>text</filter>

inside settings.

The difference is that through argument you can configure your component with everything that crosses your mind.
settings can contain only a small set of attributes. The most used ones. (Sorry, I don't have a list with all of them).

You can probably find them in the xsd file that validates the xml you are editing.

3
  • Yes that's true, I know they both work same, but is it any possiblities to any of them is deprecated in future??
    – Himanshu
    May 16 '18 at 10:59
  • 1
    as per your answer we should follow the <setting> node to define configuration so it will be same as the magento core and also it is used in 2.2.
    – Himanshu
    May 16 '18 at 11:01
  • 3
    yes. use settings as much as possible.
    – Marius
    May 16 '18 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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