0

I have created one extension now i released i have also need some system config value where user can easily to handle this module. so i have created system.xml in adminhtml folder but its not work correctly.

Below my system.xml code

<?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="dd_invoice" translate="label" sortOrder="10">
            <label>DD</label>
        </tab>
    </system>
</config>

Please check Reply on this if any changes are needed.

Thanks

  • You have to create config.xml also To show that @Ajay Patel – Learing_Coder Jul 7 '17 at 11:16
  • can you please guide me how to do this? – Ajay Patel Jul 7 '17 at 11:16
  • I think config.xml its for set default value set. not require to create tab and config field. – Ajay Patel Jul 7 '17 at 11:18
0

You have to Put these code in system.xml

file path:

<?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="dd_invoice" translate="label" sortOrder="10">
            <label>Ewall</label>
        </tab>
    </system>
</config>

then You have to create config.xml

file Path:app/code/Extension/Module/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <dd_invoice>
            <general>
                <enable>1</enable>
                <time_insec>5</time_insec>
            </general>
        </dd_invoice>
    </default>
</config>
  • what is time_insec?? – Ajay Patel Jul 7 '17 at 11:21
  • Those are my fields In tab..You can give your tab fields @AjayPatel – Learing_Coder Jul 7 '17 at 11:22
  • sorry dude this not work for me. – Ajay Patel Jul 7 '17 at 11:24
  • Chnage Sort order Once @AjayPatel – Learing_Coder Jul 7 '17 at 11:25
  • ohh... my site is down with this error : Warning: Invalid argument supplied for foreach() in – Ajay Patel Jul 7 '17 at 11:27
0

You should see:

The system.xml is a configuration file which is used to create configuration fields in Magento 2 System Configuration. You will need this if your module has some settings which the admin needs to set. You can go to Store -> Setting -> Configuration to check how it look like.

Fore More:
https://www.mageplaza.com/magento-2-module-development/create-system-xml-configuration-magento-2.html

0

Create Sections In Order to Display. If there are no sections it wont be visible in Configuration

Try this code

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="DDD" translate="label" sortOrder="20">
            <label>DDD</label>
        </tab>
        <section id="mymodule" translate="label" sortOrder="20" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>My Module</label>
            <tab>DDD</tab>
            <resource>Namespace_Modulename::config_mymodule</resource>
            <group id="general" translate="label" sortOrder="1" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>General Configuration</label>
                <field id="active" translate="label comment" sortOrder="20" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable My Module</label>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
            </group>
        </section> 
    </system>
</config>

Update

Add the acl file in

yourmodulepath/etc/acl.xml

<?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="Namespace_Modulename::config_mymodule" title="My Module"/>
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>
  • No luck with this sorry – Ajay Patel Jul 7 '17 at 11:31
  • Have you tried clearing cache? What error are you getting ? – Priyank Jul 7 '17 at 11:32
  • Warning: Invalid argument supplied for foreach() in – Ajay Patel Jul 7 '17 at 11:34
  • I assume the error is coming from somewhere else. This code works for me. – Priyank Jul 7 '17 at 11:35
  • what is this config_mymodule? – Ajay Patel Jul 7 '17 at 11:36

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.