Note that there are some explanatory texts on larger screens.

plurals
  1. POButton redirecting to the grid page
    text
    copied!<p>I have a custom module 'banner' and in which I have added a button in its second tab(only two tabs for the module). when click on that button, it is submitting my banner automatically and then go to the grid page(i e it acts as just another save button). But the function of this button is to add an uploading image field.ie whenever the button is clicked, it should add an image form field to my tab file. This is my tab file.</p> <pre><code>&lt;?php class Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Image extends Mage_Adminhtml_Block_Widget_Form { protected function _prepareForm() { $form = new Varien_Data_Form(); $this-&gt;setForm($form); $fieldset = $form-&gt;addFieldset('banner_image', array('legend'=&gt;Mage::helper('banner')-&gt;__('Banner Image'))); //declaring a new custom form field and adding $fieldset-&gt;addType('add_button', 'Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Field_Custom'); $fieldset-&gt;addField('banner_img_add_button', 'add_button', array( 'title' =&gt; Mage::helper('banner')-&gt;__('Add Banner Image'), 'id' =&gt; 'add_banner_img_button', 'class' =&gt; 'scalable save', 'style' =&gt; '', 'onclick' =&gt; 'banner.add(this)', 'type' =&gt; 'button', )); return parent::_prepareForm(); } } </code></pre> <p>this is my button defining file</p> <pre><code>&lt;?php class Karaokeshop_Banner_Block_Adminhtml_Banner_Edit_Tab_Field_Custom extends Varien_Data_Form_Element_Abstract { public function __construct($attributes=array()) { parent::__construct($attributes); } public function getElementHtml() { $value = $this-&gt;getTitle(); $onclick=$this-&gt;getOnclick(); $class=$this-&gt;getClass(); $id=$this-&gt;getId(); $style=$this-&gt;getStyle(); $type=$this-&gt;getType(); $html='&lt;button id="'.$id.'" class="'.$class.'" style="'.$style.'" onclick="'.$onclick.'" type="'.$type.'" title="'.$value.'"&gt;'.$value.' &lt;/button&gt;'; $html .= '&lt;p id="' . $this-&gt;getHtmlId() . '"'. $this-&gt;serialize($this-&gt;getHtmlAttributes()) .'&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ var banner = { add : function(obj) { }, }; //]]&gt; &lt;/script&gt; &lt;/p&gt;'; return $html; } } </code></pre> <p>what should i do to change my button to an add button? what should I do to avoid this submitting functionality of the button. Please help me. Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload