Magento - Add a button to system.xml with method attached to it

Posted by vrnet on Stack Overflow See other posts from Stack Overflow or by vrnet
Published on 2010-06-16T14:53:58Z Indexed on 2010/06/16 22:22 UTC
Read the original article Hit count: 222

Filed under:

Hi,

I have created a module that has an "export like" method running regularly as defined in my module's cron area of the config.xml file. But I'd like to give the user the ability to run this export method on demand by adding a "Run now" button in the system configuration, thus using the system.xml file.

It seems that the "frontend type" button may be working as I've tried and it adds a tiny clickable button in the config section. But I am not able to attach a method nor a label on the button itself.

I thought about adding a button in the "Grid.php" file of the module but this not what I'd like to do as it does fit with my acl.

Below is my system.xml file with the "button" frontend type.

Does anyone have a clue on how to :

  • add a label/value to the button
  • add a class to the button
  • add a method to call when the button is clicked

Many thanks for your help !

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
     ...
         <fields>
          ...
          <run translate="label">
           <label>Run now</label>
           <frontend_type>button</frontend_type>
           <backend_model>SOME BACKEND MODEL</backend_model>
           <sort_order>20</sort_order>
           <show_in_default>1</show_in_default>
           <show_in_website>1</show_in_website>
           <show_in_store>1</show_in_store>
          </run>
         </fields>
...
    </config>

© Stack Overflow or respective owner

Related posts about magento