代码之家  ›  专栏  ›  技术社区  ›  Tim Fountain

布局中的Zend_Dojo_窗体

  •  3
  • Tim Fountain  · 技术社区  · 14 年前

    我有一个zend-dojo-u表单,我已经从我的视图(它工作得很好)移到了我的布局,因为它在每一页上都很有用。然而,在布局中,表单不再有效-没有dijit元素出现,并且其行为与普通HTML表单一样。

    以下是我的引导程序的相关部分:

    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),表单无法正常工作。

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

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

    但这没什么区别。

    我发现 this question 这听起来和我的问题非常相似,但是被接受的答案只是在布局中显示了包括Dojo助手在内的内容,我已经在做了。

    1 回复  |  直到 14 年前
        1
  •  4
  •   Max Gordon    14 年前

      <?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>