Magento Add Event onlick on System Configuration Custom Module Field -
nowhere can find definition search. in mymodule namespace/modulename/etc/system.xml have:
<faq_input translate="label"> <label>question collor: </label> <comment>example: #000000</comment> <frontend_type>text</frontend_type> <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> </faq_input>
i need add onclick
event like:
<input type="text" onclik="code(myevent)" value="xxx" >
you need use <frontend_model>
, can find examples in core (eg in app/code/core/mage/catalog/etc/system.xml
).
the frontend model must block inheriting mage_adminhtml_block_system_config_form_field
, has _getelementhtml()
method can apply own code form element before rendering it. eg :
protected function _getelementhtml(varien_data_form_element_abstract $element) { $element->setonclick('launchexample();'); $html = $element->getelementhtml(); $html .= '<script type="text/javascript">function launchexample(){ alert("this example"); }</script>'; return $html; }
Comments
Post a Comment