how to extract data from subform in zendframework1
i need to perform a loop on data returned from a subform in zendframework 1.
i seem to have run into a bit of trouble understanding how to extract the
information once its returned by the post.
This is the zend subform.
$e = new Zend_Form_Element('quantity');
$e
->setValue($tieredPrice->quantity)
->setDecorators($this->_tieredPriceElementDecorators);
$sub->addElement($e);
This is the returned values:
array(5) { ["comments"]=> string(19) "testing new format " [5]=> array(6)
{ ["quantity"]=> string(3) "222" ["price"]=> string(3) "220" ["rrp"]=>
string(2) "22" ["sampleId"]=> string(5) "42960" ["id"]=> string(1) "5"
["delete"]=> string(1) "0" } [6]=> array(6) { ["quantity"]=> string(4)
"7777" ["price"]=> string(4) "2022" ["rrp"]=> string(2) "22"
["sampleId"]=> string(5) "42960" ["id"]=> string(1) "6" ["delete"]=>
string(1) "0" } [7]=> array(devil) { ["quantity"]=> string(5) "23243"
["price"]=> string(2) "22" ["rrp"]=> string(2) "22" ["sampleId"]=>
string(5) "42960" ["id"]=> string(1) "7" ["delete"]=> string(1) "0" }
["submit"]=> string(4) "Save" }
this is my attempt to seek out the subform data and loop round it.
public function processTieredPriceForm(EP3D_Form_Product_ProductSample
$form, array $data, $sampleId ) { $this->_sampleId = (int)$sampleId;
if ($form->isValid($data)) { foreach($data as $tieredPrice) { $sub =
$form->getSubForm($tieredPrice['id']);
$tieredPrice['quantity'] = $sub->getValue('quantity');
$tieredPrice['price'] = $sub->getValue('price');
$tieredPrice['rrp'] = $sub->getValue('rrp');
$tieredPrice->save();
}
The error message that i received was:
Illegal string offset 'id'
i would really appreciate any advice on this matter.
warm regards
Andreea
No comments:
Post a Comment