associated array elements in zend form

Posted by ToonMariner on Stack Overflow See other posts from Stack Overflow or by ToonMariner
Published on 2010-06-12T17:34:40Z Indexed on 2010/06/12 17:42 UTC
Read the original article Hit count: 257

Filed under:

Hi,

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

© Stack Overflow or respective owner

Related posts about zend-framework