Zend_Form输出没有主HTML HEAD BODY标记

时间:2010-10-06 12:23:48

标签: php zend-framework zend-form

在我的index/index操作中,我正在调用我创建的表单类,并在index.phtml视图中输出表单

<?php
echo $this->form;

但是当我查看页面源代码时,我得到的只是表单标记。我没有获得任何HTML HEAD BODY标记来使其成为有效的标记页面。如何将这些添加到我的所有页面?

我有layouts/scripts/layout.phtml但我不确定使用它的正确方法是什么。

2 个答案:

答案 0 :(得分:3)

听起来你没有启用布局。

这样做的典型方法是通过configs/application.ini file:

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.layout.layout = "layout"

文件application/layouts/scripts/layout.phtml应该包含模板的html代码,通常采用(如@Alkexander的答案中所述)视图助手headLink()headScript()等。< / p>

请参阅Zend Framework: Documentation: Using Zend_Layout

答案 1 :(得分:1)

使用通用布局。在这个布局中,借助View Helpers创建doctype,head ...

$this->getHead('jquery');
$this->headLink()->appendStylesheet('/styles/common.css');
echo $this->headTitle();
echo $this->headMeta();
echo $this->headScript();
echo $this->headLink();
echo $this->headStyle();