The select input is an extension of the same class as the radio input and thus has all of the same arguments. There is however an additional, optional argument available to customise the select field. The basic implementation of the select field is the same as the radio field except the PHP class “Select” is called instead:
1 2 3 4 5 |
$form->select = new Select('Please select one of the following', array( 'Choice one', 'Choice two', 'Choice three' )); |
Size: The third argument sets the size of the select field, if the value is set to False then the field will be a drop down select input, otherwise a integer can be given which dictates how many options will be shown. If the number of options is greater than the integer given, a scroll bar will appear on the field so all options can still be accessed.
Due to the extra argument in position three, arguments three and four from the radio field are arguments four and five respectively in the selct field. Below is an example, customised select field:
1 2 3 4 5 6 |
// 3 options but car is not valid,2 options are shown at a time with a scroll bar to access the third $form->select = new Select('Please select one of the following', array( 'One' => 'Choice one, dont choose', 'car' => 'Choice two', 'Choice three' ), 2, true, array('car')); |