如何通过读取表模式动态创建 Zend Form 对象?
我有一个项目,其中一个表有太多列(例如 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用 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,