-
Notifications
You must be signed in to change notification settings - Fork 5
Select and Radio Checkbox groups
stevewest edited this page Feb 11, 2013
·
5 revisions
Selects can be created simply by creating a new instance of a Select
and adding Option
s and/or Optgroup
s to it.
<?php
//Create the select element
$select = new Select();
//Add some regular options
$select[] = new Option()->setContent('red');
$select[] = new Option()->setContent('green');
$select[] = new Option()->setContent('black');
//Create a new optgroup
$optGroup1 = new Optgroup();
//And add some options to it
$optGroup1[] = new Option()->setContent('one');
$optGroup1[] = new Option()->setContent('two');
$optGroup1[] = new Option()->setContent('three');
//Add the group to the select
$select[] = $optGroup1;
The constructed Select
can then be added to a form as normal.
To do