Magento 2 Configuration – Expanded Configuration Groups

magento2system.xml

We used to have the expanded element in the group options when setting the system.xml file, e.g.

<sections>
  <groups>
    <groupx>
       <expanded>1</expanded>

but it's no longer there in the new structure in Magento 2, I checked system_file.xsd and couldn't find it. Is there an alternative in Magento 2 to have all the groups expanded by default.

Best Answer

You can use <attribute type="expanded">1</attribute>

Ex:

<section id="helloworld" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
    <class>separator-top</class>
    <label>Hello World</label>
    <tab>helloworld</tab>
    <resource>Amit_Helloworld::hello_configuration</resource>
    <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
        <label>General Configuration</label>
        <attribute type="expanded">1</attribute>
        <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>Module Enable</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
        </field>
        <field id="display_text" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
            <label>Display Text</label>
            <comment>This text will display on the frontend.</comment>
        </field>
    </group>
</section>
Related Topic