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

asked Jul 7, 2017 at 11:14
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? 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. 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>
answered Jul 7, 2017 at 11:20
6
  • what is time_insec?? 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. 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 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

answered Jul 7, 2017 at 11:30
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>
answered Jul 7, 2017 at 11:24
6
  • No luck with this sorry Commented Jul 7, 2017 at 11:31
  • Have you tried clearing cache? What error are you getting ? Commented Jul 7, 2017 at 11:32
  • Warning: Invalid argument supplied for foreach() in Commented Jul 7, 2017 at 11:34
  • I assume the error is coming from somewhere else. This code works for me. Commented Jul 7, 2017 at 11:35
  • what is this config_mymodule? Commented Jul 7, 2017 at 11:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.