2008年9月30日星期二

[fw-mvc] Using Zend_Form with table rows

I am looking to create a Zend_Form which displays and processes
checkboxes for a dynamic data table:

Date Time Destination
Tag
2008-09-14 13:20:02 London [ X ]
2008-09-14 10:42:14 London [ X ]
2008-09-05 10:50:20 Hemel Hempstead [ X ]


{ Submit }

How do you achieve this with Zend_Form? It must be a fairly common use case.

What I have done so far is:

x Create a form with a checkbox element for each table row:

$form = new Zend_Form();
foreach ($row)
{
$form->addElement('checkbox', $row->id);
}
$form->setElementDecorators(array(
'ViewHelper',
'Label'
));
$form->setDecorators(array(
'Form'
));
return $form;

x Render elements individually in the view script whilst looping
through data:

<td><?php echo
$this->taggingForm->getElement($row->id)->render($this); ?></td>

What I cannot figure out how to do is wrap the form element around the
entire table.

Any ideas?

Thanks

*Daniel Skinner*

没有评论: