我开始使用zend框架。我遇到了这个问题的形式。 当在浏览器中打开localhost/item/create时,只显示hello,表单不呈现。zend框架窗体没有显示
我做了什么: 我在我的项目创造了一个控制器zf.sh create controller item
然后zf.sh create action create item
。 库文件夹里,创建APP-> forms-> ItemEditor.php
<?php
class App_forms_ItemEditor extends Zend_Form
{
public function __construct()
{
$email = $this->createElement('text', 'email');
$email->setLabel('Your email address:');
$email->setRequired(TRUE);
$email->addValidator(new Zend_Validate_EmailAddress());
$email->addFilters(array(
new Zend_Filter_StringTrim(),
new Zend_Filter_StringToLower()
));
$email->setAttrib('size', 40);
$this->addElement($email);
}
}
宣布在的application.ini文件命名空间
autoloaderNamespaces[] = "App_"
内,则须─> scripts->用品 - > create.phtml这样做:
hello
<?php
echo $this->form->render();
?>
,然后里面ItemController.php:
public function createAction()
{
$this->view->form=new App_forms_ItemEditor();
}
只在浏览器中显示hello,表格的其余部分未显示。任何人都可以指出我做错了什么。 谢谢
你有没有看HTML源(在你的浏览器)? – zerkms 2011-02-08 05:26:25