1

I had created new module in magento2, When I create new tab get error:

Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in ...\vendor\magento\module-config\Model\Config\Structure\Mapper\Sorting.php on line 34

This code in system.xml file.

   <?xml version="1.0"?>
<!--
/**
 * @author Magento Addons Team
 * @copyright Copyright (c) 2015 Magento Addons (https://www.magentoaddons.com)
 * @package Custom_Base
 */ 
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="new_module" translate="label" sortOrder="100">
            <label>New module</label>
        </tab>
        <section id="base" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Base Configuration</label>
            <tab>new_module</tab>
            <resource>Custom_Base::config_module</resource>
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Base</label>
                <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable Base</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </section>
    </system>
</config>

Many thanks!

3
  • Have you remove var folder? Nov 18, 2016 at 5:06
  • Code is working perfectly. For double check please remove system.xml and check again still error is showing or not? Nov 18, 2016 at 5:43
  • 1
    i follow code of @manthandave, it work.
    – xanka
    Nov 18, 2016 at 6:44

1 Answer 1

6

There is extra space before <?xml version="1.0"?>. Otherwise your code works for me.

Try after removing space.

Below Code:

<?xml version="1.0"?>
    <!--
    /**
     * @author Magento Addons Team
     * @copyright Copyright (c) 2015 Magento Addons (https://www.magentoaddons.com)
     * @package Custom_Base
     */ 
    -->
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <system>
            <tab id="new_module" translate="label" sortOrder="100">
                <label>New module</label>
            </tab>
            <section id="base" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Base Configuration</label>
                <tab>new_module</tab>
                <resource>Custom_Base::config_module</resource>
                <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Base</label>
                    <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Enable Base</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                    </field>
                </group>
            </section>
        </system>
    </config>
  • Please Delete VAR/GENERATION directory
  • Clear the cache and also remove cache folder from VAR directory
  • Run cache:clean and cache:flush Command and then try
1
  • Happy to help keep helping :) Nov 18, 2016 at 6:43

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.