Zend 似乎不想加载我创建的表单

发布于 2024-09-28 15:13:24 字数 1190 浏览 4 评论 0原文

嘿, 我似乎正在攀登一条非常可怕的学习曲线。我花了几个小时才达到可以构建/编写代码的程度。我最初希望能够在其各自的模块内存储表单或模型,例如: ./application/module/ModuleName/forms/ClassName.php 但是当我尝试使用以下方法实例化一个类时: $form = new ModuleName_Form_ClassName( );它失败了。因此,我想通过将其移动到默认模块来简化一切。但是它仍然不起作用。我还是做错了什么。我不知道是什么。

在我的控制器操作中,我有以下内容:

// some other code
$form = new Form_Login();

加载操作时,我收到此错误消息:

Fatal error: Class 'Form_Login' not found in /some folder/www/application/modules/default/controllers/AdministrationController.php on line 22

我的 application.ini 包含:

appnamespace = "SomeModule"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = 

表单存储在 ./application/modules/default/forms/Login.php

1 内。我该如何解决这个问题?我收到的错误消息几乎没有用。

2.我真的认为如果有某种方法可以调试 __autoload() 函数,我所有的问题都可能得到解决。不是吗?

3.难道没有办法使用默认模块内另一个模块的模型/表单吗?这就是我想做的。我认为这会让一切变得更加结构化。如果这是不可能的,我根本看不出这有什么用...

干杯,

一位生病的 Zend 开发新手。

Hey,
I seem to be climbing a pretty horrible learning curve. It's taking me hours to even get to the point where I can structure/write code. I originally wanted to be able to store a form or a model inside its respective module, for example: ./application/module/ModuleName/forms/ClassName.php but when I tried to instantiate a class with: $form = new ModuleName_Form_ClassName(); it failed. Therefore, I thought I would simplify everything by moving it to the default module. However it still isn't working. I'm still doing something wrong. I've no idea what.

Inside my controller action I have this:

// some other code
$form = new Form_Login();

On loading the action, I get this error message:

Fatal error: Class 'Form_Login' not found in /some folder/www/application/modules/default/controllers/AdministrationController.php on line 22

My application.ini contains:

appnamespace = "SomeModule"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = 

The form is stored inside ./application/modules/default/forms/Login.php

1. How can I troubleshoot this? The error message I am getting is next to useless.

2. I really think all of my problems might be solved if there was some way of debugging the __autoload() function. Is there not?

3. Can there not be a way of using models/forms from another Module inside the default module? That is what I wanted to do. I thought it would make everything more structured. If this isn't possible I just can't see how this would be useful at all...

Cheers,

An ailing newbie Zend developer.

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

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

发布评论

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

评论(1

紫罗兰の梦幻 2024-10-05 15:13:24

听起来你第一次就差点就拥有了。假设您的模块是用户,您的表单是登录。为了使 application/module/users/forms/Login.php 工作:

  • 该文件中定义的表单类需要称为 Users_Form_Login
  • 您需要 资源。在 application.ini 中使用 module[] = 来初始化模块资源(您拥有)。
  • 您需要该模块的模块引导程序(这就是设置模块自动加载器的原因)。所以至少你需要一个像这样的引导类:

class Users_Bootstrap extends Zend_Application_Module_Bootstrap
{

}

定义于application/module/users/Bootstrap.php。路径区分大小写。

我同意自动加载器可能很难调试,不幸的是,它是要么有效要么无效的事情之一,但是一旦你设置了它,你就可以忘记它。希望以上内容能够回答您的第三个问题 - 是的,您可以使用默认模块内另一个模块中的表单。

Sounds like you almost had it the first time. Let's say your module is Users and your form Login. In order for application/module/users/forms/Login.php to work:

  • The form class defined in that file needs to be called Users_Form_Login
  • You need resources.modules[] = in your application.ini to initialise the module resource (which you have)
  • You need a module bootstrap for that module (this is what sets up the module autoloader). So minimally you need a bootstrap class like this:

.

class Users_Bootstrap extends Zend_Application_Module_Bootstrap
{

}

defined at application/module/users/Bootstrap.php. The paths are case sensitive.

I agree that the autoloader can be quite difficult to debug, unfortunately it's one of those things that either works or it doesn't, but once you have it setup you can forget about it. Hopefully the above will answer your third question - yes you can use forms from another module inside the default one.

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