3

I have followed below link and created both "system.xml" and "acl.xml" at their respective locations.

https://stackoverflow.com/questions/32614392/magento-2-system-xml-in-custom-module

But instead of creating a custom system config tab and setting for this module, it gives error as following in a report generated:

a:4:{i:0;s:138:"Notice: Undefined index: id in /var/www/html/magento-2/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php on line 59";i:1;s:6805:"#0 /var/www/html/magento-2/vendor/magento/module-config/Model/Config/Structure/Element/Iterator.php(59): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined index...', '/var/www/html/m...', 59, Array)

Anyone can clarify what could be the issue?

/Darsh/Banner/etc/adminhtml/system.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
    <system>
        <!-- Add new Tab -->
        <tab id="darsh" translate="label" sortOrder="300">
            <label>Darsh Banner</label>
        </tab>
        <section id="darsh_banner" translate="label" type="text" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Helloworld</label>
            <tab>darsh_banner</tab>
            <!-- resource tag name which we have to defined in the acl.xml -->
            <resource>Darsh_Banner::config_darsh_banner</resource>
        </section>
        <group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>General Options</label>
            <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Enabled</label>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            </field>
        </group>
    </system>
</config>

and /Darsh/Banner/etc/acl.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
    <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="Darsh_Banner::config_darsh_banner" title="Helloworld Section" sortOrder="80" />
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>
7

First mistake is .xsd file configuration, In magento 2 stable release it should be

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">

and second mistake is section should be darsh instead of darsh_banner

third mistake is

<tab>darsh_banner</tab> It should be

<tab>darsh</tab>
| improve this answer | |
  • 1
    And the namespace schema location for the acl.xml should be urn:magento:framework:Acl/etc/acl.xsd – Robbie Averill Dec 15 '15 at 22:31

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.