Question

Nowhere can I find a definition for which to search. In mymodule namespace/modulename/etc/system.xml I 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" >
Was it helpful?

Solution

You need to use a <frontend_model>, for which you can find some examples in the core (eg in app/code/core/Mage/Catalog/etc/system.xml).

The frontend model must be a block inheriting from Mage_Adminhtml_Block_System_Config_Form_Field, which has a _getElementHtml() method where you can apply your own code to the 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 is an example"); }</script>';
    return $html;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top