zend 形式的关联数组元素 [英] associated array elements in zend form

查看:33
本文介绍了zend 形式的关联数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直试图为此找到解决方案,但运气不佳......

需要用一组复选框呈现一个表单,每个复选框都有一个关联的文本框.

给定一个数组数组('Dave'=>23,'Pete'=>12,'Si'=>43);

结果标记应该产生:

<label><input type="checkbox" name="user_id[]" id="user_id-1" value="23"/>Dave</label><label for="job-1">作业:</label><input type="text" name="job[]" id="job-1"/>

<div><label><input type="checkbox" name="user_id[]" id="user_id-2" value="12"/>Pete</label><label for="job-2">作业:</label><input type="text" name="job[]" id="job-2"/>

<div><label><input type="checkbox" name="user_id[]" id="user_id-3" value="43"/>Si</label><label for="job-3">作业:</label><input type="text" name="job[]" id="job-3"/>

完整的 zend noob,因此感谢任何帮助(包括装饰器等)

谢谢大佬

解决方案

没有自定义元素就无法完成.我建议观看 http://www.zendcasts.com/写作复合zend_form-elements/2010/03/

Been trying to find a solution for this for a while with not much luck...

Need to render a form with an array of checkboxes each having an associated textbox.

given an array of array('Dave'=>23,'Pete'=>12,'Si'=>43);

the resulting mark-up should yield:

<div>
<label><input type="checkbox" name="user_id[]" id="user_id-1" value="23" />Dave</label>
<label for="job-1">Job:</label><input type="text" name="job[]" id="job-1" />
</div>
<div>
<label><input type="checkbox" name="user_id[]" id="user_id-2" value="12" />Pete</label>
<label for="job-2">Job:</label><input type="text" name="job[]" id="job-2" />
</div>
<div>
<label><input type="checkbox" name="user_id[]" id="user_id-3" value="43" />Si</label>
<label for="job-3">Job:</label><input type="text" name="job[]" id="job-3" />
</div>

Complete zend noob so any help appreciuated (including decorators etc.)

Thanks peeps

解决方案

Can't be done without custom elements. I'd suggest watching http://www.zendcasts.com/writing-composite-zend_form-elements/2010/03/

这篇关于zend 形式的关联数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆