I would like to add module On/Off option in Configuration for custom extension.

I have used below code and add into my system.xml but when I select option No module is not off.

<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">

Is there any anther code I have to do in other file ?

Or is there wrong in this code ?

  • Have you remove var/generataion folder – Rakesh Jesadiya Aug 4 '17 at 8:55
  • Still not working. – Hitesh Vaghasiya Aug 4 '17 at 9:01
  • are you add condition in xml file ifconfig="sectionid/groupid/fieldid" – Sagar Dobariya Aug 4 '17 at 9:59

Try below snippet:

<group id="test" translate="label" type="text" sortOrder="350" showInDefault="1" showInWebsite="1" showInStore="0">
    <label>Your Title</label>
    <field id="enable_module" translate="label" type="select" showInDefault="1" canRestore="1">
  • hi @Ashish, how to show default as No – jafar pinjar Mar 7 '19 at 14:10
  • Also can you tell me how to read this value? – jafar pinjar Mar 7 '19 at 14:21
  • Refre this: magento.stackexchange.com/a/90797/62614 – Ashish Viradiya Mar 7 '19 at 15:10
  • <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> this line show the selelect button option yes/no.. can you guyes please tell me how can button knows module should be off while selelect no and on while select yes. – irshad Nov 22 '19 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.