Zend_Dojo_Form in layout

I have a Zend_Dojo_Form, which I have moved from my view (where it works fine) to my layout, as it will be useful on every page. However, in the layout, the form no longer works - not one of the dijit elements appears, and it behaves in the same way as a regular HTML form.

Here is the relevant part of my boot file:

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

There are no errors (JS or ZF), the form simply does not work as it should.

I assume that I need Dojo to include the Layout view in some way. I tried changing the layout part of the boot method above:

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

but it didn’t matter.

I found this question that is very similar to my problem, but the accepted answer just shows, including the Dojo helper in the layout that I am already doing.

+3
1

, , , , :

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

, echo $this → dojo() $this- > form- > render(), Zend_Dojo.

+4

Source: https://habr.com/ru/post/1767330/


All Articles