{html_options} is a custom function that creates the html <select><option> group with the assigned data. It takes care of which item(s) are selected by default as well.
Attribute Name | Type | Required | Default | Description |
---|---|---|---|---|
values | array | Yes, unless using options attribute | n/a | An array of values for dropdown |
output | array | Yes, unless using options attribute | n/a | An array of output for dropdown |
selected | string/array | No | empty | The selected option element(s) |
options | associative array | Yes, unless using values and output | n/a | An associative array of values and output |
name | string | No | empty | Name of select group |
Required attributes are values and output, unless you use the combined options instead.
If the optional name attribute is given, the <select></select> tags are created, otherwise ONLY the <option> list is generated.
If a given value is an array, it will treat it as an html <optgroup>, and display the groups. Recursion is supported with <optgroup>.
All parameters that are not in the list above are printed as name/value-pairs inside the <select> tag. They are ignored if the optional name is not given.
All output is XHTML compliant.
Example 8-13. Dropdown with seperate arrays for values and ouptut
The above arrays would be output with the following template (note the use of the php count() function as a modifier to set the select size).
The above example would output:
|
Example 8-14. Database example (eg ADODB or PEAR)
Where a template could be as follows. Note the use of the truncate modifier.
|
Example 8-15. Dropdown's with <optgroup>
The script above and the following template
would output:
|
See also {html_checkboxes} and {html_radios}