Skip to content

Instantly share code, notes, and snippets.

@Swader
Created September 10, 2012 16:44
Show Gist options
  • Save Swader/3692042 to your computer and use it in GitHub Desktop.
Save Swader/3692042 to your computer and use it in GitHub Desktop.
ZF2 : Populating a select element
// Using Zend\Select form element
$oSelect = new Select('someName');
$oSelect->setAttribute('id', 'mySelect')->setLabel('This is a select box');
$aData = array(
'Option 1' => 'value1',
'Option 2' => 'value2',
array('label' => 'Option 3', 'selected' => true, 'value' => 'value3') // For default selection
);
$oSelect->setOptions(array('options', $aData));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment