zend_form配置问题

发布于 2024-11-27 19:59:35 字数 922 浏览 6 评论 0 原文

我的结构如下:

/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... 函数...

I have a structure like follows:

/application
.....
--/modules
----/structure
------/controllers
--------/indexController.php
------/forms
--------/Department.php //here class Structure_Form_Department extends Zend_Form

in indexController.php

...
public function saveAction()
    {
        $request = $this->getRequest();
        $form = new Structure_Form_Department();//<-- error
....
}

and i get error

Fatal error: Class 'Structure_Form_Department' not found

when try to zf enable form module - receive :

An Error Has Occurred                         
 This project already has forms enabled.

i think this is a config-like problem... but do not understand what i need to do...

EDIT 1

found good solution here

but for some way zend starts repeat executing _init... functions from default bootstrap.php....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云柯 2024-12-04 19:59:35

几个月前我也遇到了类似的问题,我通过编写以下代码得到了解决方案:

在 application.ini 中

autoloadernamespaces[] = "Structure_"

、在 Bootstrap.php 中

protected function _initAutoload()
    {
        $autoloader=new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Structure',
                'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'Structure'
            ));
    }

以及在 index.php 中,

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH),
    get_include_path(),
)));

如果它不起作用,请告诉我......

I was also facing a similar problem few months ago and I got the solution by writing following code :

In application.ini

autoloadernamespaces[] = "Structure_"

In Bootstrap.php

protected function _initAutoload()
    {
        $autoloader=new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Structure',
                'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'Structure'
            ));
    }

And at the index.php

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    realpath(APPLICATION_PATH),
    get_include_path(),
)));

Please let me know if it doesn't works.....

旧时模样 2024-12-04 19:59:35

我想在 Structure_Form_Department 前面添加 Application 会起作用。

Application_Structure_Form_Department()

或者您可能想在 config.ini 中指定从 appnamespace = "Application"appnamespace = ''

我在github上有一些代码。您可以看到这些模块是如何工作的。

$contactForm = new Contact_Form_Contact();

表单名称是

class contact_Form_Contact extends Zend_Form

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 of Structure_Form_Department will work.

ie

Application_Structure_Form_Department()

Or you may want to tell in the config.ini the from appnamespace = "Application" to appnamespace = ''.

I have some piece of code in github. You can see how the modules work.

$contactForm = new Contact_Form_Contact();

Name of form is

class contact_Form_Contact extends Zend_Form

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文