我有一个 Zend_Dojo_Form,我已经从我的视图(它工作正常的地方)移动到我的布局,因为它在每个页面上都会有用。然而,在布局中,表单不再起作用 - 没有任何 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),表单无法正常工作。
我假设我需要 Dojo 以某种方式启用布局视图。我尝试将上面的引导方法的布局部分更改为:
$layout = Zend_Layout::startMvc(array(
'layoutPath' => '../application/layouts',
'layout' => 'default'
));
$view = $layout->getView();
Zend_Dojo::enableView($view);
$layout->setView($view);
但这没有任何区别。
我发现这个问题听起来与我的问题非常相似,但接受的答案只显示在布局中包括 dojo 助手,我已经在这样做了。