Reputation: 501
I tried build form for a list of books. And i want make to update every quantity position in every row. I thought i can create dynamic form with one field like quantity.
$zendFormUpdate = new Zend_Form;
for ($i = 0; $i < 4; $i++){
$quantity[$i] = $this->addElement('text','quantity'.$i,[
'required' => false,
]);
}
$this->view->forms = ['formupdate' => $zendFormUpdate];
And now i would like ask you, how can i get this fields ? I am using code below but i can't get anything
<html>
<body>
<p>
<form>
<?php for ($i = 0; $i < 4; $i++){ ?>
<?php echo $this->forms['formupdate']->quantity.$i; ?>
<?php } ?>
</form>
</p>
</body>
</html>
Upvotes: 1
Views: 32
Reputation: 22783
Try:
// note the s after ->form, as well
$this->forms['formupdate']->getElement( 'quantity' . $i );
But since it's a typographical error, this:
$this->forms['formupdate']->{ 'quantity' . $i };
should work as well. I forgot you could access Zend_Form
elements in this manner too.
Upvotes: 1