0

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">
       <label>Enabled</label>
       <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>

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
1

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">
        <label>Enabled</label>
        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
    </field>
</group>
  • hi @Ashish, how to show default as No – jafar pinjar Mar 7 at 14:10
  • Also can you tell me how to read this value? – jafar pinjar Mar 7 at 14:21
  • <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 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.