Zend 应用程序的设计建议
寻求一些建议\对我的应用程序结构的改进
用户登录并显示欢迎消息和选项菜单 每个选项都指向相同的控制器,例如 OptionController,但具有不同的操作
/option/abc
/option/def
OptionController.php
{
abcAction()
defAction()
}
我有不同操作的原因是因为
当呈现表单并且用户输入输入时,每个选项都需要不同的表单,请求将再次提交到验证控制器,每个选项有不同的操作。 我需要基本的表单验证+自定义业务逻辑,
我让它“工作”,但不认为这是一个好方法。 想法?
Looking for some advice \ improvements on the structure of my application
user logs in and is presented with a welcome message and a menu of options
each option points to the same controller e.g OptionController but with different actions
/option/abc
/option/def
OptionController.php
{
abcAction()
defAction()
}
the reason why I have different actions is because each option will require a different form
when the form is rendered and the user enters input the request is submitted to a validate controller again with a different action per option. i need basic form validation + custom business logic
I have it "working" but don't think it's a good way to do it. Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您总结的结构不是任务的艺术(显示、验证),而是用您的话来说,
例如“选项”(:
表单的配置(包括验证)应该位于从 Zend_Form 扩展的自己的类中)存储在其自己的文件夹中,例如 APPLICATION_PATH.'/forms'(请参阅 ZF - 自动加载器),显示和验证表单可以驻留在同一操作中,我通常将它们拆分为添加和编辑(但使用相同的表单类)。两者)
您在所有控制器中需要的任务最好作为操作或视图助手来实现。
I would recommend a structure where you summarize not the art (display, validated) of task, but the, in your words, "options"
for example (:
the configs for your forms (including validation) should be in own classes extended from Zend_Form which are stored in its own folder. eg APPLICATION_PATH.'/forms'. (see ZF - autoloader) displaying and validating forms can reside in the same action, i usaly split them into add and edit. (but using the same form class for both)
task's you need in all controllers are best to be implemented as action or view helpers.