2

I am trying to disable admin menu when module enable set to No in configuration.

I have tried to use ifconfig="section/group/field" there but that's not working.
Here is my admin menu code.

Vendor\Module\etc\adminhtml\menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Vendor_Module::sample" title="Sample" translate="title" module="Vendor_Module" sortOrder="60" parent="Vendor_Module::sample1" action="sample/sample/index/" resource="Vendor_Module::sample"/>
    </menu>
</config>

1 Answer 1

11

on the add tag add an attribute dependsOnConfig="section/group/field"

<add id="Vendor_Module::sample" 
     title="Sample" translate="title" 
     module="Vendor_Module" 
     sortOrder="60" 
     parent="Vendor_Module::sample1" 
     action="sample/sample/index/" 
     resource="Vendor_Module::sample"
     dependsOnConfig="section/group/field"
/>
1
  • Thanks @Marius. What kind of scope value will consider by dependsOnConfig to read? Currently, I added store view specific scope to that Enable/Disable field. If I'll change the status from any one store view dependsOnConfig getting false value. Jul 16, 2019 at 6:05

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.