Search code examples
phpzend-frameworkzend-formzend-form-element

Custom Radio Element View in Zend Framework


Currently have a custom Form Element View:

class Apply_View_Helper_JQueryUiFormRadio extends Zend_View_Helper_FormElement

My form is as follows

$form->addElement('radio', 'name', array(
 'label' => 'etc...",

How would I instantiate this replacing the 'radio' string in the addElement method?


Solution

  • Each class which extends Zend_Form_Element has public proterty "helper" so you can do it in that way:

    $element = new Zend_Form_Element_Radio('item');
    $element->helper = 'jQueryUiFormRadio';
    $this->addElement($element);
    

    In your case Apply_View_Helper_ must be added to zend_view helper script path.