phpzend-frameworkzend-formzend-form-element

Zend-form without Zend-Framework MVC - viewscript isn't displaying elements, but they exists and are displayed by var_dump()


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


Solution

  • 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);