Hi i used this code to add button in custom module in magento admin.

I need to create a "Run Now" button and my code created a button without text. Like screenshot:

enter image description here

My question is : how to add "Run Now" text on button?

File: system.xml

<enabled translate="label">
                            <label>Enable Module</label>

<module_btn translate="label">
                <label>Product Button</label>

Here is the code of /adminhtml_system_config_button file:

class Weo_Productlist_Block_Adminhtml_System_Config_Button extends Mage_Adminhtml_Block_System_Config_Form_Field

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
        $html = parent::_getElementHtml($element);

        $html = $this->getLayout()->createBlock('adminhtml/widget_button')
                    ->setLabel('Run Now')
                    ->setOnClick("return callajaxRequestController();")

       return $html;


  • i think change label value <label>Product Button</label> – Yogesh Nov 15 '17 at 11:15
  • @Yogesh its add label to button, not text on button. – pooja Nov 15 '17 at 11:18
  • @pooja add code of your weo_productlist/adminhtml_system_config_button file – Piyush Nov 15 '17 at 11:35
  • @Piyush i updated the code of weo_productlist/adminhtml_system_config_button file. – pooja Nov 15 '17 at 11:39
  • @pooja check my answer and let me know if any issue – Piyush Nov 15 '17 at 11:41

To change button label you have to change setLabel value in file Weo_Productlist_Block_Adminhtml_System_Config_Button

$html = $this->getLayout()->createBlock('adminhtml/widget_button')
                    ->setLabel('Run Now') // change your label here
                    ->setOnClick("return callajaxRequestController();")
| improve this answer | |
  • yes i did it. but by this code <depends><enabled>1</enabled></depends> tag not working. i need to hide the button if "Enable Module" field value set to "No". If i commented above code in "Weo_Productlist_Block_Adminhtml_System_Config_Button" file , button is shows without label. – pooja Nov 15 '17 at 11:44
  • @pooja that code is fine, if it is not working confirm the field name <enabled>. Also mark this answer as accepted if it helped you – Piyush Nov 15 '17 at 11:48
  • Please check my updated system.xml file code. – pooja Nov 15 '17 at 11:52
  • @pooja your code looks fine. is it displaying button when enabled is No ? – Piyush Nov 15 '17 at 12:00
  • 1
    thank you. i did it by adding an hidden field, Please check this answer: magento.stackexchange.com/questions/65246/… – pooja Nov 16 '17 at 4:49

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.