OptionsHelper
extends Helper
in package
This is a helper class is used to handle draw select options form elements
Tags
Table of Contents
- __construct() : mixed
- The constructor at this point does nothing
- render() : mixed
- Draws an HTML select tag according to the supplied parameters
- renderLinkDropDown() : mixed
- Creates a dropdown where selecting an item redirects to a given url.
Methods
__construct()
The constructor at this point does nothing
public
__construct() : mixed
Return values
mixed —render()
Draws an HTML select tag according to the supplied parameters
public
render(string $id, string $name, array<string|int, mixed> $options, string $selected[, mixed $onchange_action = false ][, array<string|int, mixed> $additional_attributes = [] ]) : mixed
Parameters
- $id : string
-
the id attribute the select tag should have If empty string id attribute not echo'd
- $name : string
-
the name this form element should use If empty string name attribute not echo'd
- $options : array<string|int, mixed>
-
an array of key value pairs for the options tags of this select element. The key is used as an option tag's value and the value being used as its contents. If the value is empty in a key value pair then the key is taken as the label of a new optgroup.
- $selected : string
-
which option (note singular -- no support for selecting more than one) should be set as selected in the select tag
- $onchange_action : mixed = false
-
if true then submit the parent form if this drop down is changed, if false, normal dropdown, if a callback function, then when change call callback
- $additional_attributes : array<string|int, mixed> = []
-
associative array of attributes => values to add to the open select tag if present
Return values
mixed —renderLinkDropDown()
Creates a dropdown where selecting an item redirects to a given url.
public
renderLinkDropDown(string $id, array<string|int, mixed> $options, string $selected, string $url_prefix[, bool $as_list = false ][, string $class_list = "" ][, string $show_top = "" ]) : mixed
Parameters
- $id : string
-
the id attribute the select tag should have If empty string id attribute not echo'd
- $options : array<string|int, mixed>
-
an array of key value pairs for the options tags of this select element. The key is used as an option tag's value and the value being used as its contents. If the value is empty in a key value pair then the key is taken as the label of a new optgroup.
- $selected : string
-
which url should be selected in dropdown
- $url_prefix : string
-
keys in $options should correspond to urls. if such a key doesn't begin with http, it is assumed to be a url suffix and the value $url_prefix is put before it to get a complete url before the window location is changed.
- $as_list : bool = false
-
whether to output the result as a dropdown or as an unordered list.
- $class_list : string = ""
-
a string of additional CSS classes for outer- most div tag
- $show_top : string = ""
-
if empty then the selected item value will be the clickable link at the top of the drop down, if non-empty then the text of $show_top will be used.