I have this simplified form:
$this->form = new \Zend_Form();
$this->form->setAction($request->currentPath());
$this->form->setMethod('post');
$this->form->addElement('text', 'firstName', array(
'label' => 'First name: ',
));
and I want to render the element individually in my view page. Like so:
<?php echo $form->firstName->renderViewHelper() ?>
But I keep getting this error:
Fatal error: Uncaught exception ‘Zend_Form_Decorator_Exception’ with message ‘ViewHelper decorator cannot render without a registered view object’.
What am I doing wrong? I have pretty much followed the Zend Documentation on this page:
http://framework.zend.com/manual/en/learning.form.decorators.individual.html
Sincerely,
Why
You need to pass the form object after creating it in one of your controllers to your view script to render the form elements.
And in your view script do something like