使用 Zend_Form 在视图和模型中进行验证
在本书中(链接转到我感兴趣的部分)建议您可以使用 Zend_Form 的单个实例来放置模型和视图验证。我想知道到底如何做到这一点,考虑到形式可能与模型的结构不完全对应。如何才能实现这一目标?不重复进行验证的代码听起来很合乎逻辑,但我总是单独进行。
In this book (the link goes to the part I'm interested in) it is suggested that you could use a single instance of Zend_Form to put both Model and View validations. I'm wondering exactly how to do this, considering the forms will probably not correspond exactly to the structure of the models. How can this be achieved? It sounds logical to not duplicate the code that does validation, but I have always done it separately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ZF 项目负责人 Matthew Weier O'Phinney 撰写的这篇文章解释了一种方法:
http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html
This article from ZF Project Lead Matthew Weier O'Phinney explains one approach:
http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html