Hello,

I have come across a situation where I have to create form elements based on information stored in the database. For each value I want to create a checkbox form field element.

Without Zend_Form I would do something like this:

[snip]
<form name="edituser" action="/user/edit" method="post" />
Email: <input type="text" name="username" value="<?php echo $email; ?>" /> <br />
       Roles: <br />
               <?php
               $sql = "SELECT name FROM role";
               $result = $db->fetchAll($sql);
               foreach ($result as $row) {
                       $role = $row['name'];
                       echo $role;
echo "<input type=\"checkbox\" name=\"row[$role]\" value=\"set\" /> <br />";
               }
?> <input type="submit" name="submit" value="submit" /> </form>
[/snip]

How can I achieve the objective using Zend_Form? Specifically, I would like to know how to build form elements whose names are represented by arrays. I have read the subform section of the manual. But I'm unable to understand how to implement it in this situation. I would greatly appreciate if somebody can show an example.


--

With warm regards,
Sudheer. S
http://binaryvibes.co.in


Reply via email to