I need to create a custom dropdown having values of Enable/Disable in config file in magento 1.9 .How can I achieve this? can anyone help me?

1 Answer 1


Why would you want to create it in config file? Do you want to edit module's configuration settings? If so, you need to do that in system.xml like shown below :

<?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">
        <tab id="fme" translate="label" sortOrder="250">
        <section id="vendor_module" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Module Enable</label>

It'll make a Module Enable/Disable toggle in your module's configurations. Look under label "General" and in your config.xml you can set default value for this field like below :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
  • As of now I edited in system.xml file m but how I add <source_model> in system.xml file and how I access while value is selected in dropdown in my files.
    – Mahesh1343
    Oct 23, 2020 at 12:59
  • See my edit and tell me if it helps. :) Oct 23, 2020 at 13:07
  • I answered the question you asked in this thread, if you've another question, you can ask separately so it would help others too. :) Oct 23, 2020 at 13:09
  • Already , I have one custom module , in that I need a dropdown , as of now I edited the system.xml file in that module and add a dropdown , but for me how I pass the value to the dropdown from model by using <source_model></source_model>
    – Mahesh1343
    Oct 23, 2020 at 13:10
  • Like in this site excellencemagentoblog.com/blog/2011/09/22/…
    – Mahesh1343
    Oct 23, 2020 at 13:13

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.