Workaround for Zend_Dojo_Form when you render elements individually and dijit.byId() returns ‘undefined’

filled under:
June 11, 2010 

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.

Leave a Reply

Your email address will not be published.Required fields are marked bold.

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  1. Tom ( March 11, 2011 at 12:41 pm )

    Thank you, very much. It helped a lot.

  2. faustus eberle ( December 11, 2011 at 4:40 am )

    Definitely imagine that that you said. Your favourite reason appeared to be at the net the simplest factor to bear in mind of. I say to you, I certainly get annoyed whilst other people think about worries that they plainly don’t recognize about. You managed to hit the nail upon the top and also outlined out the whole thing without having side effect , people can take a signal. Will likely be back to get more. Thank you