Question

I creat system configurations in custom module. I am unable to get required changes in store->configurations.

The code I wrote for system.xml is as follows:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
    <tab id="zipcodevalidator" translate="label" sortOrder="1">
        <label>Zipcode Validator</label>
    </tab>
    <section id="validatorsettings" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>Validator Settings</label>
        <tab>zipcodevalidator</tab>
        <resource>Tm_Zipcode::config</resource>
        <group id="general_settings">
            <label>General Settings</label>
            <field id="enable_disable" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Enable</label>
                <!-- <sorurce_model>Tm\Zipcode\Model\Yesno</source_model> -->
            </field>
            <field id="sucess_message" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Sucess Message</label>
                <comment>Use {zipcode} as zipcode placeholder and {days} as number of days placeholder</comment>
            </field>
            <field id="error_message" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Error Message</label>
                <comment>Use {zipcode} as zipcode placeholder</comment>
            </field>
    </section>
</system>
</config>

The code for acl.xml is as follows

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn: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">
                        <resource id="Tm_Zipcode::config_zipcode" title="Zipcode Section" sortOrder="50" />
                    </resource>
                </resource>
            </resource>
        </resource>
    </resources>
</acl>
</config>  

I'm really stuck with this. Please help.

Was it helpful?

Solution

You did this change in your code.

  1. Change your resource that specify in acl.xml.
  2. You need to add </group> in your above code.

replace your code with this one.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
    <tab id="zipcodevalidator" translate="label" sortOrder="1">
        <label>Zipcode Validator</label>
    </tab>
    <section id="validatorsettings" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
        <class>separator-top</class>
        <label>Validator Settings</label>
        <tab>zipcodevalidator</tab>
        <resource>Tm_Zipcode::config_zipcode</resource>
        <group id="general_settings">
            <label>General Settings</label>
            <field id="enable_disable" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Enable</label>
                <!-- <sorurce_model>Tm\Zipcode\Model\Yesno</source_model> -->
            </field>
            <field id="sucess_message" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Sucess Message</label>
                <comment>Use {zipcode} as zipcode placeholder and {days} as number of days placeholder</comment>
            </field>
            <field id="error_message" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Error Message</label>
                <comment>Use {zipcode} as zipcode placeholder</comment>
            </field>
      </group>
    </section>
</system>
</config>

OTHER TIPS

you made a mistake in resource tab.

In you ACl configuration the resource id is Tm_Zipcode::config_zipcode .

So you have to use the same in the system.xml like

<resource>Tm_Zipcode::config_zipcode</resource>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top