2010-09-30 100 views
3

我有一个Zend_Dojo_Form,我已经从我的视图(它工作正常)移到我的布局,因为它是在每个页面上都有用的东西。然而,在布局中,表单不再有效 - 没有任何dijit元素出现,它的行为就像普通的HTML表单一样。Zend_Dojo_Form在布局

这里是我的自举的相关部分:

protected function _initView() 
{ 
    Zend_Layout::startMvc(array(
     'layoutPath' => '../application/layouts', 
     'layout' => 'default' 
    )); 

    $view = new Zend_View(); 
    $view->setEncoding('UTF-8') 
     ->doctype('HTML5'); 

    // init Dojo 
    Zend_Dojo::enableView($view); 
    $view->dojo()->enable() 
       ->setCdnVersion('1.5') 
       ->requireModule('dojo.data.ItemFileWriteStore') 
       [...] 
       ->addStyleSheetModule('dijit.themes.tundra'); 

    // assign the view to the viewRenderer, so it will be used by the MVC actions 
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); 
    $viewRenderer->setView($view); 

    return $view; 
} 

没有任何错误(JS或ZF),形式是行不通的,因为它应该。

我假设我需要Dojo以某种方式启用布局视图。我尝试将上面的引导方法的布局部分更改为:

$layout = Zend_Layout::startMvc(array(
    'layoutPath' => '../application/layouts', 
    'layout' => 'default' 
)); 
$view = $layout->getView(); 
Zend_Dojo::enableView($view); 
$layout->setView($view); 

但是没有任何区别。

我发现this question这听起来与我的问题非常相似,但接受的答案只是显示了包括布局中的dojo helper,我已经在做。

回答

4

这是最有可能是由于你有布局的建议在docs:

<?php echo $this->doctype() ?> 
    <html> 
    <head> 
     <?php echo $this->headTitle() ?> 
     <?php echo $this->headMeta() ?> 
     <?php echo $this->headLink() ?> 
     <?php echo $this->headStyle() ?> 
    <?php if ($this->dojo()->isEnabled()){ 
     $this->dojo()->setLocalPath('/js/dojo/dojo.js') 
        ->addStyleSheetModule('dijit.themes.tundra'); 
     echo $this->dojo(); 
    } 
    ?> 
     <?php echo $this->headScript() ?> 
    </head> 
    <body class="tundra"> 
     <?php echo $this->layout()->content ?> 
     <?php echo $this->inlineScript() ?> 
    </body> 
    </html> 

的问题是回声$这个 - >道场()必须是$这个 - >表格后, - > render()否则所需模块将不会在Zend_Dojo中注册。