Created
September 10, 2012 16:44
-
-
Save Swader/3692042 to your computer and use it in GitHub Desktop.
ZF2 : Populating a select element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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