When I try to do something like
<?=$this->element->mailCiteCheck?>
nothing is displaying.
However, when I do:
<?=var_dump($this->element->mailCiteCheck);?>
I get:
object(Zend_Form_Element_Checkbox)#118 (33) {
["checked"]=>
bool(false)
["helper"]=>
string(12) "formCheckbox"
["options"]=>
array(2) {
["checkedValue"]=>
string(1) "1"
["uncheckedValue"]=>
And so on... so how can I display elements of this form?
And when I do
<?=$this->element->mailCiteCheck;die();?>
I get this warning:
ViewHelper decorator cannot render without a registered view object
As noted in the link provided by @Hikaru:
By default, Zend_Form and Zend_Form_Element will attempt to use the view object initialized in the
ViewRenderer
So instead of overriding the form's render() method or manually calling $form->setView($view), an alternate approach is to just set the view into the ViewRenderer, possibly during Bootstrap:
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view = $view;
The answer was to set view to all form elements:
$view = new Zend_View();
$view->addScriptPath(APPLICATION_FORM_SCRIPT_PATH);
$view->addBasePath(APPLICATION_SCRIPT_PATH);
$replyForm = new Form_MailReply();
$replyForm->setView($view);
foreach ($replyForm as $item){
$item->setView($view);
}
$replyForm->render($view);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With