1

I want to add multiple sections under the same tab in admin panel. Here is what I have for system.xml (cut off config tag):

<system>
    <!-- Add new Tab -->
    <tab id="xxx" translate="label" sortOrder="5000">
        <label>XXXX</label>
    </tab>
    <section id="ldap" translate="label" type="text" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>Ldap</label>
        <tab>xxx</tab>
        <!-- resource tag name which we have to defined in the acl.xml -->
        <resource>XXXX_XXXX::config</resource>

        <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>General Options</label>
            <field id="active" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Enabled</label>
            </field>
        </group>
    </section>
    <section id="smtp" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>SMTP</label>
        <tab>xxx</tab>
        <!-- resource tag name which we have to defined in the acl.xml -->
        <resource>XXXX_XXXX::config</resource>

        <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>General Options</label>
            <field id="active" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Enabled</label>
            </field>
        </group>
    </section>
</system>

and acl.xml:

<acl>
    <resources>
        <resource id="Magento_Backend::admin">
            <resource id="Magento_Backend::stores">
                <resource id="Magento_Backend::stores_settings">
                    <resource id="Magento_Config::config">
                        <!-- this resource id we can use in system.xml for section -->
                        <resource id="XXXX_XXXX::config" title="Ldap" sortOrder="10" />
                    </resource>
                </resource>
            </resource>
        </resource>
    </resources>
</acl>

The error shows "Warning: Invalid argument supplied for foreach() in /var/www/magento2/vendor/magento/module-config/Model/Config/Structure/Mapper/Sorting.php on line 34"

1
  • Under modules etc/adminhtml/routes.xml, add route id and frontName values as ldap and smtp, something like this: <router id="admin"> <route id="ldap" frontName="ldap"> <module name="yourModuleName" /> </route> <route id="smtp" frontName="smtp"> <module name="urModuleName" /> </route> </router>
    – Sushivam
    Commented Jun 8, 2016 at 9:22

1 Answer 1

1

The problem arises because the section id should be unique across the whole application. So I changed the id and it works.

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.