### Attributes:
- multiple - show a multiple select box. If set to 'checkbox' multiple checkboxes will be
created instead.
- empty - If true, the empty select option is shown. If a string,
that string is displayed as the empty element.
- escape - If true contents of options will be HTML entity encoded. Defaults to true.
- val The selected value of the input.
- disabled - Control the disabled attribute. When creating a select box, set to true to disable the
select box. Set to an array to disable specific option elements.
### Using options
A simple array will create normal options:
$options = [1 => 'one', 2 => 'two'];
$this->Form->select('Model.field', $options));
While a nested options array will create optgroups with options inside them.
$options = [
1 => 'bill',
'fred' => [
2 => 'fred',
3 => 'fred jr.'
]
];
$this->Form->select('Model.field', $options);
If you have multiple options that need to have the same value attribute, you can
use an array of arrays to express this:
$options = [
['text' => 'United states', 'value' => 'USA'],
['text' => 'USA', 'value' => 'USA'],
];
public select ( string $fieldName, array | Traversable $options = [], array $attributes = [] ) : string | ||
$fieldName | string | Name attribute of the SELECT |
$options | array | Traversable | Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the SELECT element |
$attributes | array | The HTML attributes of the select element. |
return | string | Formatted SELECT element |