我有一个 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);
但这没有任何区别。
I found 这个问题 https://stackoverflow.com/questions/2869435/zend-dojo-form-not-rendering-in-layout这听起来与我的问题非常相似,但接受的答案只是显示在布局中包括道场助手,我已经在这样做了。
这很可能是因为您拥有文档中建议的布局:
<?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 中注册。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)