Skip to content

Instantly share code, notes, and snippets.

@aronkerr
Last active December 20, 2015 21:18
Show Gist options
  • Save aronkerr/6196208 to your computer and use it in GitHub Desktop.
Save aronkerr/6196208 to your computer and use it in GitHub Desktop.
Get individual form elements from ZF2 collection
<?php
// Itterate over the collection and grap the elements
foreach($form->get('collectionName')->getIterator() as $fieldset)
{
echo $this->formRow($fieldset->get('elementName'));
echo $this->formRow($fieldset->get('elementAnotherElementName'));
}
// Render the collection template
echo $this->formCollection()->renderTemplate($form->get('collectionName'));
@webdevilopers
Copy link

I think the parentheses are missing in l. 15 for formCollection() view helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment