如何在 Zend 的多个视图中使用单个子表单
我是 Zend 框架的新手。我的一个应用程序在多个视图中带有国家、州、地区、城市
的动态下拉列表。 因此,我想将其保留为通用组件,并根据我们的需要在任何地方进行渲染。任何人都可以建议我一个简单且更好的解决方案来使用 Zend 框架实现这一目标。
I am new bie with Zend framework. One of my application carries dynamic Drop down list of country,state, district, city
in multiple views.
So I would like to keep this as a common component and render anywhere with our needs. Can anybody can suggest me a simple and better solution to achieve this with Zend framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在表单中需要这些列表,一个不错的选择可能是编写一个子表单并在需要的地方调用它。如果您在视图中需要这些列表,那么视图助手可能是一个不错的选择。
If you need these lists in a Form a good choice could be to write a sub-form and call it where you need. If you need these lists in the views, a good choice could be a view-helper.
您可以编写自己的类来扩展 Zend_Form_Element_Library 并将其放置在库文件夹中。
我通常在 /library 中创建自己的文件夹(即称为 MyApp),并将所有扩展 Zend 类的类(名称以“MyApp_”开头)放在那里。我还在配置中添加了一个命名空间,以便自动加载该类。
You could write your own class which extends Zend_Form_Element_Library and i.e. place it in the library folder.
I usually create my own folder in /library (i.e. called MyApp) and put there all my classes (names start with 'MyApp_') which extend Zend classes. I also add a namespace to the config so as to load that classes automatically.