How to enable /disble module in admin configuration setting .....

I also refer Magento 2 - add Enable / Disable field for custom module how to enable/disable full module


1 Answer 1


You can add the field Enable/Disable in the System config and use the value entered there. Check the below example of system config file. It should always be named as system.xml and put inside the <Module>/etc/adminhtml directory.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <tab id="helloworld" translate="label" sortOrder="100">
            <!-- add a new tab with id helloworld -->
            <label>Hello World</label>
        <section id="helloworld" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <!-- add a new section with id helloworld and for tab helloworld -->
            <label>Hello World Configuration</label>
            <group id="active_display" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
                <!-- add a new group with id active display -->
                <label>Hello World Configuration Options</label>
                <field id="scope" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
                    <!-- add a new field with id scope -->
                    <label>Enable Helloworld Controller</label>

Once you successfully implement the above file you will see the output in the Stores > Configurations page. Under the Tab titled "Hello World" you will see the Section "Hello World Configuration", by clicking on it, you will be sent to the configurations page of the module.

Which will have the Dropdown containing Yes and No options. select one of them and the option will be saved in the core_config_data table in the database.

To get the value in the block or helper or model or Controller or any where, you need to add dependency in the respective class's constructor.


and assign it to the member variable of the class.

To get the value, you can use $this->scopeConfig->getValue('path/to/field');

For further reference you can use the following links. http://excellencemagentoblog.com/blog/2016/04/10/magento2-system-xml/ https://magento.stackexchange.com/a/87835/16246

  • i will do it.....
    – Mahi M
    Commented Feb 9, 2018 at 6:20
  • how to disable ko template
    – Mahi M
    Commented Feb 9, 2018 at 6:57
  • To disable the ko template, you need to pass the data in the JS using some kind of options in json. Commented Feb 10, 2018 at 6:42
  • please post some more info on what you need to achieve so i can guide you more. Commented Feb 10, 2018 at 6:43
  • @thanks .... i have do it.....How to disable admin grid column
    – Mahi M
    Commented Feb 10, 2018 at 6:44

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.