Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid system.xml file #79

Closed
jahicDario opened this issue Jul 17, 2017 · 11 comments
Closed

Invalid system.xml file #79

jahicDario opened this issue Jul 17, 2017 · 11 comments

Comments

@jahicDario
Copy link

I installed module, run all post-installation commands and when I login to admin page and try to go to Stores-Configurations I get this error:
1 exception(s): Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /.../app/code/bitExpert/ForceCustomerLogin/etc/adminhtml/system.xml: Element 'resource': This element is not expected. Line: 7

@der-workfloh
Copy link
Contributor

Hi @jahicDario ,

which version of the module and of Magento 2 (2.0, 2.1; CE or EE) are you using?
Currently, I cannot reproduce this issue in our test environment with Magento 2.1 CE.

@jahicDario
Copy link
Author

Hi @websharp
I'm using Magento ver. 2.1.3 and v2.1.0-RC3 which I installed mannualy, not with composer.

@der-workfloh
Copy link
Contributor

Can you remove line 7 with the resource tag from the file, so it looks like this and try again:

<?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>
        <section id="customer" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="bitExpert_ForceCustomerLogin" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>bitExpert Force Customer Login</label>
                <field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable Module</label>
                    <comment>Configures if the module is enabled</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="url" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Target URL</label>
                    <comment>Configures the target for redirecting, if whitelist rules do not match</comment>
                </field>
            </group>
        </section>
    </system>
</config>

@jahicDario
Copy link
Author

jahicDario commented Jul 17, 2017

When I remove line 7, Configuration page is opened but there is no Force Login tab. I also compare system.xml against vendor/magento/module-config/etc/system_file.xsd and it says that there is a problem with resource.
Here is xml and xsd.
forceLoginXml.tar.gz

@der-workfloh
Copy link
Contributor

der-workfloh commented Jul 17, 2017

I get no XML validation issues with or without removing the resource tag. I used multiple external XML validators and the in-built PHPStorm validation with the XSD resolution by using bin/magento dev:urn-catalog:generate .idea/misc.xml

You may try this example

<?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>
        <section id="customer" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
            <resource>BitExpert_ForceCustomerLogin::bitexpert_force_customer_login_manage</resource>
            <group id="bitExpert_ForceCustomerLogin" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>bitExpert Force Customer Login</label>
                <field id="enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable Module</label>
                    <comment>Configures if the module is enabled</comment>
                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                </field>
                <field id="url" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Target URL</label>
                    <comment>Configures the target for redirecting, if whitelist rules do not match</comment>
                </field>
            </group>
        </section>
    </system>
</config>

@jahicDario
Copy link
Author

When I copy that in my system.xml, again page is loaded but there is no Force Login tab.

@der-workfloh
Copy link
Contributor

Did you enable the module by running bin/magento module:enable bitExpert_ForceCustomerLogin?

@jahicDario
Copy link
Author

Yes I have. Module is enabled and I can even see under customer "Force custoimer login", but it's not clickable, probably because it has to be enabled under "Force login".

@der-workfloh
Copy link
Contributor

Are you accessing the backend as a fully qualified administrator? Or are you using an administrative user with custom ACL settings?

@jahicDario
Copy link
Author

Yes, I'm accessing as first user, fully qualified administrator. I'm not sure what you mean by custom ACL settings?

@jahicDario
Copy link
Author

I don't know how and why, first time when I was installing module with composer I was getting some version mismatch error. Now I tried again and it worked. If I somehow reduce problem again, I will write here.
Thanks for fast answers.

der-workfloh pushed a commit that referenced this issue Aug 3, 2017
#79 Fixed invalid position of tag resource in system.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants