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

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

3 Answers 3

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>
6
  • what is time_insec??
    – Ajay Patel
    Commented Jul 7, 2017 at 11:21
  • Those are my fields In tab..You can give your tab fields @AjayPatel Commented Jul 7, 2017 at 11:22
  • sorry dude this not work for me.
    – Ajay Patel
    Commented Jul 7, 2017 at 11:24
  • Chnage Sort order Once @AjayPatel Commented Jul 7, 2017 at 11:25
  • ohh... my site is down with this error : Warning: Invalid argument supplied for foreach() in
    – Ajay Patel
    Commented Jul 7, 2017 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>
6
  • No luck with this sorry
    – Ajay Patel
    Commented Jul 7, 2017 at 11:31
  • Have you tried clearing cache? What error are you getting ?
    – Priyank
    Commented Jul 7, 2017 at 11:32
  • Warning: Invalid argument supplied for foreach() in
    – Ajay Patel
    Commented Jul 7, 2017 at 11:34
  • I assume the error is coming from somewhere else. This code works for me.
    – Priyank
    Commented Jul 7, 2017 at 11:35
  • what is this config_mymodule?
    – Ajay Patel
    Commented Jul 7, 2017 at 11:36

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.