title: Magento : add custom button to an admin form
body: <p>Building a custom adminhtml module. Im using a simple form. it looks like this :</p>
  
  <pre><code>&lt;?php
  
  class Namespace_Modulename_Block_Adminhtml_Modulename_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
  {
      protected function _prepareForm()
      {
          $form = new Varien_Data_Form();
          $this-&gt;setForm($form);
          $fieldset = $form-&gt;addFieldset('modulename_form',array('legend'=&gt;Mage::helper('modulename')-&gt;__('Module Data')));
  
  
      $fieldset-&gt;addField('test', 'text', array(
              'label'     =&gt; Mage::helper('modulename')-&gt;__('Test'),
              'name'      =&gt; 'test',
      ));
  
      // I want to add a custom button here. Say an action called "Add Option".
      //Clicking this action adds input boxes or dropdowns to the form that are to
      //to be included in the post when submitting the form (obviously).
  </code></pre>
  
  <p>I have been looking for a solution on Stack overflow and have not been able to find something that could help. I have then tried searching for something similar present in the Mage Core. </p>
  
  <p>In the admin panel, if i go to [Catalog->Attributes->Manage Attributes] and click on a standard attribute like "Manufacturer" for example, on the second tab, called "Manage labels/Options" i see the following screen :</p>
  
  <p><img src="https://i.stack.imgur.com/1TrZd.png" alt="add options"></p>
  
  <p>There is a button and action which allows me to add options (in the form of textboxes) to the form. Identifying this as something i am trying to replicate, i went into the core to try and figure out what to do. If i open the following files (<strong>Magento Enteprise 12.0.2</strong>) :</p>
  
  <p>Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options</p>
  
  <p>I see it is empty, but extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract</p>
  
  <p>and I have gone through this file, but little makes sense to me. Am I going down the wrong way? How can I achieve something similar, a button and action which adds fields to a admin form?</p>
  
  <p>thanks</p>