Zend_Dojo_Form在布局中不呈现 [英] Zend_Dojo_Form not rendering in layout

查看:135
本文介绍了Zend_Dojo_Form在布局中不呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于将Zend_Dojo_Form添加到Zend_layouts中的快速问题。



我有一个Zend_Dojo_Form,我想在用于特定控制器的布局中显示。我可以将表单添加到布局中,而不会出现任何问题,但dojo元素无法呈现,就像我将表单添加到标准视图中一样。



有没有理由会这样呢?我需要对布局进行某些操作,以便在布局中启用嵌入式表单的组件。任何其他使用此布局工作的视图中添加的dojo启用表单都可以正常工作。



我的表单按照常规方式创建:

 类QuickAddJobForm扩展Zend_Dojo_Form {


public function init(){

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


/ *我们现在创建元素* /
$ 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,....));

在控制器中,我声明了init函数中的布局和窗体:

  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;

在我的布局我想要我的表单:

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

为什么在布局中添加此窗体无法渲染/添加Dojo元素?所有当前正在显示的都是文本框,而不是其他组件,如ComboBoxes / FilteringSelects等...



提前感谢。

解决方案

这是我在layout.phtml中有的

 < HEAD> 

< style type =text / cssmedia =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()包括/ JS /道场/道场/的dojo.js');
echo $ this-> dojo();
}
?>
< / head>
< body class =tundra>

在我的引导我使用

  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');
}

现在我可以在我的视图脚本中随时调用$ this->表单, Dojo正确呈现



我遇到的问题是Dojo不能在Modal窗口中呈现表单


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.

解决方案

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

这篇关于Zend_Dojo_Form在布局中不呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆