zend_form配置问题
我的结构如下:
/application
.....
--/modules
----/structure
------/controllers
--------/indexController.php
------/forms
--------/Department.php //here class Structure_Form_Department extends Zend_Form
在indexController.php 中
...
public function saveAction()
{
$request = $this->getRequest();
$form = new Structure_Form_Department();//<-- error
....
}
,我收到错误
致命错误:找不到类“Structure_Form_Department”
致命错误:尝试zf启用表单模块
时
An Error Has Occurred
This project already has forms enabled.
- 接收:我认为这是一个类似配置的问题...但不明白我需要做什么...
编辑1
找到了很好的解决方案这里
但以某种方式zend开始重复执行默认 bootstrap.php 中的 _init...
函数...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
几个月前我也遇到了类似的问题,我通过编写以下代码得到了解决方案:
在 application.ini 中
、在 Bootstrap.php 中
以及在 index.php 中,
如果它不起作用,请告诉我......
I was also facing a similar problem few months ago and I got the solution by writing following code :
In application.ini
In Bootstrap.php
And at the index.php
Please let me know if it doesn't works.....
我想在
Structure_Form_Department
前面添加Application
会起作用。即
或者您可能想在 config.ini 中指定从
appnamespace = "Application"
到appnamespace = ''
。我在github上有一些代码。您可以看到这些模块是如何工作的。
表单名称是
github 上的所有代码。一探究竟 。
https://github.com/harikt/blog /blob/master/application/modules/contact/controllers/IndexController.php
https://github.com/harikt/blog/blob/master/application/modules/contact/forms/Contact.php
I guess adding
Application
in-front ofStructure_Form_Department
will work.ie
Or you may want to tell in the config.ini the from
appnamespace = "Application"
toappnamespace = ''
.I have some piece of code in github. You can see how the modules work.
Name of form is
All codes over github. Check it out .
https://github.com/harikt/blog/blob/master/application/modules/contact/controllers/IndexController.php
https://github.com/harikt/blog/blob/master/application/modules/contact/forms/Contact.php