如何通过读取表模式动态创建 Zend Form 对象?

发布于 2025-01-05 21:02:48 字数 111 浏览 2 评论 0原文

我有一个项目,其中一个表有太多列(例如 80 或更多),并且在 Zend_Form 类中手动设置每个表成为一项痛苦的(并且容易出错)工作。有没有办法通过读取表模式并根据字段类型添加正确的元素来自动执行此操作?

I have a project where one of the tables has too many columns (like 80 or more) and setting manually each one in a Zend_Form class became a painful (and prone to errors) work. Is there a way to automatize this by reading the table schema and adding the right elements accordingly to field types?

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

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

发布评论

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

评论(1

司马昭之心 2025-01-12 21:02:48

您可以调用 describeTable() 方法,并根据其结果动态创建表单元素。 describeTable() 返回每列的数据类型,因此您可以根据列类型创建不同类型的元素。

希望有帮助,

You can call the describeTable() method in Zend_Db_Adapter and create the form elements dynamically based on its results. describeTable() returns the data type for each column, so you can create different types of elements according to the column type.

Hope that helps,

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