如何使用 Dojo 循环遍历表单元素/字段
有谁知道如何使用 Dojo 循环遍历表单中的所有元素? (表单本身是通过 ZendFW Zend_Dojo_Form 创建的)
我想做的是遍历表单中的所有字段/输入,如果可能的话,更改它们的 id 值。然而,即使不可能更改字段的 ID,我仍然想知道如何循环遍历表单元素并访问它们的属性/值。
谢谢!
Does anybody know how one would go about looping through all the elements in a form using Dojo? (the form itself was created through the ZendFW Zend_Dojo_Form)
What I'm trying to do is go through all the fields/inputs in the form, and if possible, change their id value. However, even if its not possible to change the ID's of fields I would still love to know how to loop through the form elements and access their properties/values.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Zend 添加了一个在页面上呈现的 Dijit 变量,称为“zendDijit”。迭代它,通过 id 获取原始元素(它是数组中的第一项),然后使用 dojo 设置 id 使用:
以前从未这样做过,但应该可以工作
Zend adds a variable of Dijits rendered on the page called 'zendDijits'. Iterate through that, getting the original element by id (it's the first item in the array), then using dojo set the id using:
Never done it before but that should work
由于元素是对象,这很简单:
$form 显然是类中的表单对象。即:
正如我所说,它是一个对象,因此可以轻松更改属性。 var_dump 一个元素,看看如果您不确定可以更改什么
As elements are objects it's easy:
$form is obviously your form object from your class. Ie:
As I said, it's an object so properties can be changed easily. var_dump an element to see what you can change if you're unsure