Workaround for Zend_Dojo_Form when you render elements individually and dijit.byId() returns 'undefined'
Problem: When you render the form as a whole (i.e: <?php echo $this->form ?>
), everything works fine, but when you render each element separate, the zendDijit {"id":"yourFormId","params":{"dojoType":"dijit.form.Form"}}
is missing. This causes to break the validation/xhr process, because dijit.byId()
returns only an 'undefined' value.
Solution: Go to your View, where you render your form and add the following:
$form = $this->form; $this->dojo()->setDijit($form->getId(), array('dojoType' => 'dijit.form.Form')); // add form tag ... // add elements ...
It took me nearly 3 hours to figure this out ;)
Hope this helps someone.