(on Tuesday, 30 September 2008, 10:51 AM +0100):
> 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?
Change your $form->setDecorators() statement to:
$form->setDecorators(array(
array('HtmlTag', array('tag' => 'table')),
'Form',
));
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论