I have tried to add new field in System configuration in magento 2. I have used the below code, but I am getting this error:
Could not create an acl object: Invalid XML in file path/to/file
Suggest me the correct way to do this. Thanks in advance!!
acl.xml
<?xml version="1.0"?>
<!--
/**
* Location: magento2_root/app/code/Namespace/Module/etc/acl.xml
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.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_Module::config" title="Custom Settings" sortOrder="50" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
system.xml
<?xml version="1.0"?>
<!--
/**
* Location: magento2_root/app/code/Namespace/Module/etc/adminhtml/system.xml
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="settings" translate="label" sortOrder="1000">
<label>Settings</label>
</tab>
<section id="example_section" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Example config section</label>
<tab>settings</tab>
<resource>Namespace_Module::config</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="facebook" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Facebook</label>
</field>
<field id="textarea_example" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Textarea example</label>
</field>
</group>
</section>
</system>
</config>
Qaisar Satti
32.6k18 gold badges88 silver badges138 bronze badges
asked Sep 21, 2016 at 10:00
Deeban Babu
50510 silver badges23 bronze badges
1 Answer 1
problem with your acl.xml replace this urn:magento:module:Magento_Config:etc/system_file.xsd with urn:magento:framework:Acl/etc/acl.xsd
<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="Spacename_Module::config" title="Module configuration" sortOrder="50" />
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
answered Sep 21, 2016 at 10:11
Qaisar Satti
32.6k18 gold badges88 silver badges138 bronze badges
-
Same error occurDeeban Babu– Deeban Babu2016年09月21日 10:19:11 +00:00Commented Sep 21, 2016 at 10:19
-
@DeebanBabu updated tested code... follow thisQaisar Satti– Qaisar Satti2016年09月21日 10:21:54 +00:00Commented Sep 21, 2016 at 10:21
-
What is the issue in my xmlDeeban Babu– Deeban Babu2016年09月21日 10:23:27 +00:00Commented Sep 21, 2016 at 10:23
-
@DeebanBabu i already mention the issue in your xml. rest i cannot test now so i added the working exampleQaisar Satti– Qaisar Satti2016年09月21日 10:25:47 +00:00Commented Sep 21, 2016 at 10:25
-
"Could not create an acl object: Invalid XML in file ../etc/acl.xml:Premature end of data in tag config line 1Deeban Babu– Deeban Babu2016年09月21日 10:26:31 +00:00Commented Sep 21, 2016 at 10:26
default