Skip to content

Instantly share code, notes, and snippets.

@fabiocarneiro
Created October 2, 2013 17:48
Show Gist options
  • Save fabiocarneiro/6797623 to your computer and use it in GitHub Desktop.
Save fabiocarneiro/6797623 to your computer and use it in GitHub Desktop.
public function getFreightForm() {
$form = new Form();
$items = $this->session->offsetGet('list');
foreach ($items as $i => $consumer) {
$fieldset = new Fieldset($i);
foreach ($consumer->getItems() as $token => $item) {
$fieldset->add(array(
'type' => 'text',
'name' => $token,
'options' => array(
'label' => 'Price',
'value' => '123'
),
));
}
$fieldset->add(array(
'type' => 'text',
'name' => 'freight',
'options' => array(
'label' => 'Freight'
)
));
$form->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'prices',
'options' => array(
'target_element' => $fieldset
)
));
$form->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'csrf'
));
}
$inputFilter = new InputFilter();
$form->setInputFilter($inputFilter);
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment