> $this->currentModel->details; ?>" cellspacing="0">
> <caption><?php echo $this->currentModel->details; ?></caption>
> <tr>
> <th scope="col">Date</th>
> <th scope="col">Time</th>
> <th scope="col">Destination</th>
> <th scople="col">Tag</th>
> </tr>
> <?php
> foreach ($this->calls as $call):?>
> <tr>
> <th scope="row"><?php echo date('Y-m-d',
> strtotime($call->timestamp)); ?></th>
> <td><?php echo date('H:i:s', strtotime($call->timestamp)); ?></td>
> <td><?php echo $call->sourceNo; ?></td>
> <td><?php echo $call->destination; ?></td>
> <td>*<?php echo
> $this->taggingForm->getElement($call->id)->render($this); ?>*</td>
> </tr>
> <?php endforeach; ?>
> </table>
>
> Where does the $this->taggingForm->render(); call go to wrap the above
> table?
Ok, I've figured out a working solution. Any ideas on how to improve it
further?
I captured the part of the view script I wanted to wrap, then simply
rendered the Form decorator with the captured content as the argument:
<?php ob_start(); ?>
<table>
...
</table>
<?php echo $this->taggingForm->renderForm(ob_get_clean()); ?>
It gives the desired result. Is there anything that can be done to
improve the code?
Kind Regards,
*Daniel Skinner*
Daniel Skinner wrote:
> I don't see how that will help encapsulate the table within <form>
> tags. My view scripts is like:
>
> <table class="datagrid" summary="<?php echo
> $this->currentModel->details; ?>" cellspacing="0">
> <caption><?php echo $this->currentModel->details; ?></caption>
> <tr>
> <th scope="col">Date</th>
> <th scope="col">Time</th>
> <th scope="col">Destination</th>
> <th scople="col">Tag</th>
> </tr>
> <?php
> foreach ($this->calls as $call):?>
> <tr>
> <th scope="row"><?php echo date('Y-m-d',
> strtotime($call->timestamp)); ?></th>
> <td><?php echo date('H:i:s', strtotime($call->timestamp)); ?></td>
> <td><?php echo $call->sourceNo; ?></td>
> <td><?php echo $call->destination; ?></td>
> <td>*<?php echo
> $this->taggingForm->getElement($call->id)->render($this); ?>*</td>
> </tr>
> <?php endforeach; ?>
> </table>
>
> Where does the $this->taggingForm->render(); call go to wrap the above
> table?
>
> What I really didn't want to do was be forced to put all the
> presentation and table markup into the form as RawText elements as
> it's really not the place and I want to keep the table markup in the
> view script.
>
> Kind Regards,
>
> *Daniel Skinner*
>
>
>
> Matthew Weier O'Phinney wrote:
>> -- Daniel Skinner <skinner@destiny-denied.co.uk> wrote
>> (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',
>> ));
>>
>>
>
没有评论:
发表评论