Zend_Dojo_Form not rendering in layout

Posted by Grant Collins on Stack Overflow See other posts from Stack Overflow or by Grant Collins
Published on 2010-05-19T21:07:33Z Indexed on 2010/05/19 21:10 UTC
Read the original article Hit count: 145

Filed under:
|
|

Hi,

I have a quick question about adding Zend_Dojo_Form into Zend_layouts.

I have a Zend_Dojo_Form that I want to display in the layout that is used for a particular controller. I can add the form to the layout without any issue however the dojo elements fail to render, as they would do if I added the form to a standard view.

Is there any reason why this would be the case? Do I need to do something to the layout so that it will enable the components for this embedded form in the layout. Any other dojo enabled forms that are added in the view using this layout work fine.

My form is created in the usual way:

class QuickAddJobForm extends Zend_Dojo_Form{


public function init(){

    $this->setName('quickaddjobfrm')
        ->setMethod('post')
        ->setAction('/addjob/start/);


    /*We now create the elements*/
    $jobTitle = new Zend_Dojo_Form_Element_TextBox('jobtitle',
        array(
            'trim' => true              
        )
    );
    $jobTitle->setAttrib('style', 'width:200px;')
        ->addFilter('StripTags')
        ->removeDecorator('DtDdWrapper')
        ->removeDecorator('HtmlTag')
        ->removeDecorator('Label');

      ....
  $this->addElements(array($jobTitle, ....));

In the controller I declare the layout and the form in the init function:

 public function init(){
   $this->_helper->layout->setLayout('add-layout');
   $form = new QuickAddJobForm();
   $form->setDecorators(array(array('ViewScript', array('viewScript' => 'quickAddJobFormDecorator.phtml'))));

 $this->_helper->layout()->quickaddjob = $form;

In my layout Where I want the form I have:

  echo $this->layout()->quickaddjob;

Why would adding this form in the layout fail to render/add the Dojo elements? All that is currently being displayed are text boxes, rather than some of the other components such as ComboBoxes/FilteringSelects etc...

Thanks in advance.

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about zend-form