开发者

Zend_Dojo_Form not rendering in layout

开发者 https://www.devze.com 2022-12-31 03:11 出处:网络
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

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(开发者_StackOverflowarray(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.


This is what I have in my layout.phtml

<head>

    <style type="text/css" media="screen">
        @import url("<?= Zend_Controller_Front::getInstance()->getBaseUrl() ?>/includes/js/dojo/dijit/themes/tundra/tundra.css");

<?php
$this->dojo()->enable();
    if ($this->dojo()->isEnabled()) {
        $this->dojo()->setLocalPath($this->baseUrl() .  '/includes/js/dojo/dojo/dojo.js');
        echo $this->dojo();
    }
?>
</head>
<body class="tundra">

In my bootstrap I use

    protected function _initDojo()
{
    $this->bootstrap('frontController');
    $this->bootstrap('view');
    $view = $this->getResource('view');

    $appConfig = Zend_Controller_Front::getInstance()->getParam('appconfig');
    Zend_Dojo::enableView($view);
    Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
    $view->dojo()->setLocalPath(Zend_Controller_Front::getInstance()->getBaseUrl() . '/includes/js/dojo/dojo/dojo.js')
    ->addLayer(Zend_Controller_Front::getInstance()->getBaseUrl() . '/includes/js/dojo/dojo/nirvanaDojo.js')
    ->requireModule('dijit.TitlePane')
    ->requireModule('dijit.InlineEditBox')
    ->requireModule('dijit.ProgressBar')
    ->requireModule('dijit.form.DateTextBox')
    ->addStyleSheetModule('dijit.themes.tundra');
}

Now I can call $this->form anytime in my view scripts, and the Dojo renders properly

The problem I have is I can't cant Dojo to render a form in Modal window


Iam not 100% Sure, but i think you must add Dojo to your Application. Try

 $this->dojo()->enable(); 
 echo $this->dojo(); 

in your Layout.phtml


If you use Zend_Dojo_Forms in your layout be sure to render them before calling

echo $this->dojo();

You can do that with something like that:

//in HTML-Head:
$content = $form->render();
echo $this->dojo();

//later...
echo $content;
0

精彩评论

暂无评论...
验证码 换一张
取 消