Search code examples
zend-frameworkzend-framework2zend-formzend-form-elementzfcuser

How to implement something like <input type="radio" onclick="if(this.checked){myFunction()}"> by using zf2


I am using zf2 framework. So that i need to implement something like,

i have tried to find it by search it on internet but i could not find any tutorials about this problem.

Thanks


Solution

  • Try this.

        $element = new Element\Radio('name');
        $element->setAttribute('onClick', 'if(this.checked){myFunction()}');