Reputation: 515
Instead of my former viewscript, which showed my recordset as a table:
$i=1;
foreach($this->aktermine as $termin) :
?>
<tr>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->nr);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->kopfnr);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->datum);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->zeit);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->thema);?></td>
<td></td>
</tr>
<?php
$i=$i+1;
endforeach;
I built a form with decorators in the style, the next snippet shows:
$kopfnr=$this->CreateElement('text','kopfnr')
->setAttrib('size', '5');
$kopfnr->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array(array('data'=>'HtmlTag'), array('tag' => 'td'))
));
How can I use the form instead of the viewscript in the sameway? I want to see all related records and additional have the possibility to add a new record without leaving the page.
Here is my indexcontroller:
$form = new Application_Form_Aktermine();
$this->view->form = $form;
$logenr = $this->_getParam('nr', 0);
if ($logenr > 0) {
$aktermine=new Application_Model_DbTable_Aktermine();
$select=$aktermine->select()->where('kopfnr = ?', $logenr) ;
$this->view->aktermine = $aktermine->fetchAll($select);
}
First step should be: Showing all existing records in the right form fields Second Step: An Add action, which does not leave the page, but if it is possible, adds a new line at the end of the existing records, where the user can fill in new data in a new datarecord.
Upvotes: 2
Views: 58
Reputation: 1643
I'd use JavaScript to add an empty row at the end of your table plus AJAX to send the new entry back to your controller.
Upvotes: 1