Possible to add javascript to Zend_Form_Element_Radio?

Posted by Stepppo on Stack Overflow See other posts from Stack Overflow or by Stepppo
Published on 2009-10-25T04:56:10Z Indexed on 2010/05/03 16:08 UTC
Read the original article Hit count: 276

Filed under:
|

Ultimately, I'd like my Zend Form to render this HTML:

<p>Do you have any documents to upload?</p>
<p>Yes <input type="radio" value="Yes" name="uploadChoice" onClick="showTable()">&nbsp;&nbsp;No <input type="radio" value="No" name="uploadChoice" onClick="hideTable()" checked></p>

Here's what I have in my Zend_Form:

//create radio buttons
$uploadQuestion = new Zend_Form_Element_Radio('upLoadQuestion');
$uploadQuestion->setLabel('Do you have any documents to upload?')
->addMultiOptions(array(
'yes' => 'Yes',
'no' => 'No'
))
->setSeparator(' ');

The problem I'm running into is how to add the onClick="showTable()" and onClick="hideTable()" elements to their respective radio buttons.

In the alternative, I could rework the javascript and add something like onClick="toggleTable()" to the radio buttons if I can't add something different to each of the radio buttons. But, will Zend let me do that?

© Stack Overflow or respective owner

Related posts about zend-form

Related posts about php