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 PatelLearing_Coder– Learing_Coder2017年07月07日 11:16:05 +00:00Commented Jul 7, 2017 at 11:16
-
can you please guide me how to do this?Ajay Patel– Ajay Patel2017年07月07日 11:16:40 +00:00Commented 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– Ajay Patel2017年07月07日 11:18:13 +00:00Commented Jul 7, 2017 at 11:18
3 Answers 3
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– Ajay Patel2017年07月07日 11:21:51 +00:00Commented Jul 7, 2017 at 11:21
-
Those are my fields In tab..You can give your tab fields @AjayPatelLearing_Coder– Learing_Coder2017年07月07日 11:22:54 +00:00Commented Jul 7, 2017 at 11:22
-
sorry dude this not work for me.Ajay Patel– Ajay Patel2017年07月07日 11:24:00 +00:00Commented Jul 7, 2017 at 11:24
-
Chnage Sort order Once @AjayPatelLearing_Coder– Learing_Coder2017年07月07日 11:25:22 +00:00Commented Jul 7, 2017 at 11:25
-
ohh... my site is down with this error : Warning: Invalid argument supplied for foreach() inAjay Patel– Ajay Patel2017年07月07日 11:27:58 +00:00Commented Jul 7, 2017 at 11:27
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.
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 sorryAjay Patel– Ajay Patel2017年07月07日 11:31:33 +00:00Commented Jul 7, 2017 at 11:31
-
Have you tried clearing cache? What error are you getting ?Priyank– Priyank2017年07月07日 11:32:34 +00:00Commented Jul 7, 2017 at 11:32
-
Warning: Invalid argument supplied for foreach() inAjay Patel– Ajay Patel2017年07月07日 11:34:23 +00:00Commented Jul 7, 2017 at 11:34
-
I assume the error is coming from somewhere else. This code works for me.Priyank– Priyank2017年07月07日 11:35:22 +00:00Commented Jul 7, 2017 at 11:35
-
what is this config_mymodule?Ajay Patel– Ajay Patel2017年07月07日 11:36:10 +00:00Commented Jul 7, 2017 at 11:36
Explore related questions
See similar questions with these tags.