如何在 Zend 的多个视图中使用单个子表单

发布于 2024-12-23 20:10:09 字数 142 浏览 2 评论 0原文

我是 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 技术交流群。

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

发布评论

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

评论(2

旧梦荧光笔 2024-12-30 20:10:09

如果您在表单中需要这些列表,一个不错的选择可能是编写一个子表单并在需要的地方调用它。如果您在视图中需要这些列表,那么视图助手可能是一个不错的选择。

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.

北方的巷 2024-12-30 20:10:09

您可以编写自己的类来扩展 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.

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