htmlResponsiveSelect
extends htmlSelect
in package
Responsive select with label and help link.
Table of Contents
- ALIGN_BOTTOM = 3
- align to bottom
- ALIGN_CENTER = 4
- align to center
- ALIGN_LEFT = 1
- align to left
- ALIGN_RIGHT = 2
- align to right
- ALIGN_TOP = 0
- align to top
- $alignment : int|null
- alignment when inside a table
- $colspan : int|null
- colspan if inside a table
- $rowspan : int|null
- rowspan if inside a table
- $cssClasses : array<string|int, mixed>|null
- $name : string
- name of select field
- $tableCellCssClasses : array<string|int, mixed>|null
- $tableRowsToHide : array<string|int, mixed>
- $tableRowsToShow : array<string|int, mixed>
- $accessibilityLabel : string|null
- accessibility label
- $containsOptgroups : bool
- contains optgroups
- $dataAttributes : array<string|int, mixed>
- $dynamicScrolling : bool
- dynamic scrolling
- $elements : array<string|int, mixed>
- $hasDescriptiveElements : bool
- descriptive elements
- $helpID : string|null
- help ID
- $helpModule : string|null
- help module name
- $isEnabled : bool
- enabled or disabled
- $label : string
- descriptive label
- $multiSelect : bool
- allows multi-selection
- $onchangeEvent : string|null
- onchange event
- $optionCssClasses : array<string|int, mixed>
- $renderParentHtml : bool
- render HTML of parent class
- $rightToLeftTextDirection : bool
- right to left text direction
- $selectedElements : array<string|int, mixed>
- $shortLabel : bool
- short label
- $size : string
- size
- $sortElements : bool
- sorting enabled
- $transformSingleSelect : bool
- transform select boxes with one element to text
- $transient : bool
- indicates that this field should not automatically be saved in the self-service or server profile
- $width : string
- width of input element
- __construct() : mixed
- Constructor.
- addDataAttribute() : void
- Adds a data attribute.
- enableDynamicScrolling() : void
- Enable dynamic scrolling. This limits the number of select options to 10000 by dynamically adding/removing options.
- generateHTML() : array<string, string>
- Prints the HTML code for this element.
- getAccessibilityMarkup() : string
- Returns the markup for the accessibility data.
- getAlignmentString() : string
- Returns the HTML attributes for the alignment.
- getColspanString() : string
- Returns the HTML attribute for the colspan.
- getCSSClasses() : array<string|int, string>|null
- Returns the CSS classes of this element.
- getRowspanString() : string
- Returns the HTML attribute for the rowspan.
- getTableCellCSSClasses() : array<string|int, string>|null
- Returns the CSS classes of the surrounding table cell for this element.
- setAccessibilityLabel() : void
- Sets the accessibility label.
- setContainsOptgroups() : void
- Specifies if the elements are divided into optgroups.
- setCSSClasses() : void
- Adds CSS classes to this element.
- setHasDescriptiveElements() : void
- Specifies if the elements are just a simple list or an associative array (default: simple list).
- setIsEnabled() : void
- Specifies if this component is enabled and accepts user modification.
- setMultiSelect() : void
- Specifies if multi-selection is enabled (default: disabled).
- setOnchangeEvent() : void
- Sets the JavaScript code for the onchange event.
- setOptionCssClasses() : void
- Sets CSS classes for option values.
- setRightToLeftTextDirection() : void
- Specifies if the text direction should be set to right to left.
- setShortLabel() : void
- Use a short label (4 columns instead of 6) for tablet/desktop.
- setSortElements() : void
- Specifies if the elements should be sorted (default: sort).
- setTableCellCSSClasses() : void
- Adds CSS classes to the surrounding table cell for this element.
- setTableRowsToHide() : void
- This will hide the given table rows when the select is changed to the specified value.
- setTableRowsToShow() : void
- This will show the given table rows when the select is changed to the specified value.
- setTransformSingleSelect() : void
- Specifies if select boxes that contain only a single element should be transformed to a simple text field.
- setTransient() : void
- Specifies that the value should not be automatically saved when used in self-service or server profile (default: false).
- setWidth() : void
- Specifies the width of this selection box.
- getDataAttributesAsString() : string
- Returns the data attributes as rendered string.
- getShowHideSelector() : string
- Returns the selector to use to find the show/hide elements.
- printCodeForShowHideTableRows() : void
- Creates the JavaScript code to hide/show table rows based on the select value.
- printOptionsHTML() : void
- Prints the HTML code of the option tags.
Constants
ALIGN_BOTTOM
align to bottom
public
mixed
ALIGN_BOTTOM
= 3
ALIGN_CENTER
align to center
public
mixed
ALIGN_CENTER
= 4
ALIGN_LEFT
align to left
public
mixed
ALIGN_LEFT
= 1
ALIGN_RIGHT
align to right
public
mixed
ALIGN_RIGHT
= 2
ALIGN_TOP
align to top
public
mixed
ALIGN_TOP
= 0
Properties
$alignment
alignment when inside a table
public
int|null
$alignment
= \null
$colspan
colspan if inside a table
public
int|null
$colspan
= \null
$rowspan
rowspan if inside a table
public
int|null
$rowspan
= \null
$cssClasses
protected
array<string|int, mixed>|null
$cssClasses
= []
CSS classes
$name
name of select field
protected
string
$name
$tableCellCssClasses
protected
array<string|int, mixed>|null
$tableCellCssClasses
= []
table cell CSS classes
$tableRowsToHide
protected
array<string|int, mixed>
$tableRowsToHide
= []
list of enclosing table rows to hide when checked
$tableRowsToShow
protected
array<string|int, mixed>
$tableRowsToShow
= []
list of enclosing table rows to show when checked
$accessibilityLabel
accessibility label
private
string|null
$accessibilityLabel
= \null
$containsOptgroups
contains optgroups
private
bool
$containsOptgroups
= \false
$dataAttributes
private
array<string|int, mixed>
$dataAttributes
= []
data attributes
$dynamicScrolling
dynamic scrolling
private
bool
$dynamicScrolling
= \false
$elements
private
array<string|int, mixed>
$elements
elements
$hasDescriptiveElements
descriptive elements
private
bool
$hasDescriptiveElements
= \false
$helpID
help ID
private
string|null
$helpID
= \null
$helpModule
help module name
private
string|null
$helpModule
= \null
$isEnabled
enabled or disabled
private
bool
$isEnabled
= \true
$label
descriptive label
private
string
$label
$multiSelect
allows multi-selection
private
bool
$multiSelect
= \false
$onchangeEvent
onchange event
private
string|null
$onchangeEvent
= \null
$optionCssClasses
private
array<string|int, mixed>
$optionCssClasses
= []
CSS classes for values
$renderParentHtml
render HTML of parent class
private
bool
$renderParentHtml
= \false
$rightToLeftTextDirection
right to left text direction
private
bool
$rightToLeftTextDirection
= \false
$selectedElements
private
array<string|int, mixed>
$selectedElements
= []
selected elements
$shortLabel
short label
private
bool
$shortLabel
= \false
$size
size
private
string
$size
$sortElements
sorting enabled
private
bool
$sortElements
= \true
$transformSingleSelect
transform select boxes with one element to text
private
bool
$transformSingleSelect
= \true
$transient
indicates that this field should not automatically be saved in the self-service or server profile
private
bool
$transient
= \false
$width
width of input element
private
string
$width
= ''
Methods
__construct()
Constructor.
public
__construct(string $name, array<string|int, string>|array<string, string>|array<string, string[]|array> $elements, array<string|int, string> $selectedElements, string $label[, string|array<string|int, string> $helpID = null ][, int $size = 1 ]) : mixed
Parameters
- $name : string
-
element name
-
$elements
: array<string|int, string>|array<string, string>|array<string, string[]|array
> -
list of elements
- $selectedElements : array<string|int, string>
-
list of selected elements
- $label : string
-
descriptive label
- $helpID : string|array<string|int, string> = null
-
help ID or array of help ID + module name (optional)
- $size : int = 1
-
size (optional, default = 1)
Return values
mixed —addDataAttribute()
Adds a data attribute.
public
addDataAttribute(string $key, string $value) : void
Parameters
- $key : string
-
attribute name (without "data-")
- $value : string
-
attribute value
Return values
void —enableDynamicScrolling()
Enable dynamic scrolling. This limits the number of select options to 10000 by dynamically adding/removing options.
public
enableDynamicScrolling() : void
This will not be enabled when optgroups are used or the option size is less than 10000.
Return values
void —generateHTML()
Prints the HTML code for this element.
public
generateHTML(mixed $module, mixed $input, mixed $values, mixed $restricted) : array<string, string>
Parameters
- $module : mixed
-
Name of account module
- $input : mixed
-
List of meta-HTML elements
- $values : mixed
-
List of values which override the defaults in $input (name => value)
- $restricted : mixed
-
If true then no buttons will be displayed
Return values
array<string, string> —List of input field names and their type (name => type)
getAccessibilityMarkup()
Returns the markup for the accessibility data.
public
getAccessibilityMarkup() : string
Return values
string —markup to be included in HTML tag (starting with space)
getAlignmentString()
Returns the HTML attributes for the alignment.
public
getAlignmentString() : string
Return values
string —alignment HTML attributes (e.g. align="right" valign="top")
getColspanString()
Returns the HTML attribute for the colspan.
public
getColspanString() : string
Return values
string —colspan HTML attribute (e.g. colspan=3)
getCSSClasses()
Returns the CSS classes of this element.
public
getCSSClasses() : array<string|int, string>|null
Return values
array<string|int, string>|null —$classes CSS class names
getRowspanString()
Returns the HTML attribute for the rowspan.
public
getRowspanString() : string
Return values
string —rowspan HTML attribute (e.g. rowspan=3)
getTableCellCSSClasses()
Returns the CSS classes of the surrounding table cell for this element.
public
getTableCellCSSClasses() : array<string|int, string>|null
Return values
array<string|int, string>|null —CSS classes
setAccessibilityLabel()
Sets the accessibility label.
public
setAccessibilityLabel(string|null $accessibilityLabel) : void
Parameters
- $accessibilityLabel : string|null
-
label
Return values
void —setContainsOptgroups()
Specifies if the elements are divided into optgroups.
public
setContainsOptgroups(bool $containsOptgroups) : void
In this case the provided options are an array where the key is the optgroup label and the value is an array containing the options for the optgroup.
Parameters
- $containsOptgroups : bool
-
activates optgroups
Return values
void —setCSSClasses()
Adds CSS classes to this element.
public
setCSSClasses(array<string|int, string>|null $classes) : void
Parameters
- $classes : array<string|int, string>|null
-
CSS class names
Return values
void —setHasDescriptiveElements()
Specifies if the elements are just a simple list or an associative array (default: simple list).
public
setHasDescriptiveElements(bool $hasDescriptiveElements) : void
Parameters
- $hasDescriptiveElements : bool
-
activates descriptive elements
Return values
void —setIsEnabled()
Specifies if this component is enabled and accepts user modification.
public
setIsEnabled(bool $isEnabled) : void
Parameters
- $isEnabled : bool
-
enabled if true
Return values
void —setMultiSelect()
Specifies if multi-selection is enabled (default: disabled).
public
setMultiSelect(bool $multiSelect) : void
Parameters
- $multiSelect : bool
-
allows multi-selection
Return values
void —setOnchangeEvent()
Sets the JavaScript code for the onchange event.
public
setOnchangeEvent(string $onchangeEvent) : void
Parameters
- $onchangeEvent : string
-
onchange event code (e.g. myfunction();)
Return values
void —setOptionCssClasses()
Sets CSS classes for option values.
public
setOptionCssClasses(array<string, string> $optionCssClasses) : void
Parameters
- $optionCssClasses : array<string, string>
-
array('option value' => 'CSS class(es)')
Return values
void —setRightToLeftTextDirection()
Specifies if the text direction should be set to right to left.
public
setRightToLeftTextDirection(bool $rightToLeftTextDirection) : void
Parameters
- $rightToLeftTextDirection : bool
-
if true use right to left direction
Return values
void —setShortLabel()
Use a short label (4 columns instead of 6) for tablet/desktop.
public
setShortLabel() : void
Return values
void —setSortElements()
Specifies if the elements should be sorted (default: sort).
public
setSortElements(bool $sortElements) : void
Parameters
- $sortElements : bool
-
sort elements
Return values
void —setTableCellCSSClasses()
Adds CSS classes to the surrounding table cell for this element.
public
setTableCellCSSClasses(array<string|int, string>|null $classes) : void
Parameters
- $classes : array<string|int, string>|null
-
CSS class names
Return values
void —setTableRowsToHide()
This will hide the given table rows when the select is changed to the specified value.
public
setTableRowsToHide(array<string, array<string|int, string>> $tableRowsToHide) : void
The given IDs can be of any e.g. input element. Starting from this element the first parent "
Example:
Using "mycheckbox" will use this "tr" to hide/show.
Example for $tableRowsToHide:
array('yes' => array('option1', 'option2'), 'no' => array('option3'))
Parameters
- $tableRowsToHide : array<string, array<string|int, string>>
-
array of select value => array of IDs of child elements to hide
Return values
void —setTableRowsToShow()
This will show the given table rows when the select is changed to the specified value.
public
setTableRowsToShow(array<string, array<string|int, string>> $tableRowsToShow) : void
The given IDs can be of any e.g. input element. Starting from this element the first parent "
Example:
Using "mycheckbox" will use this "tr" to hide/show.
Example for $tableRowsToShow:
array('yes' => array('option1', 'option2'), 'no' => array('option3'))
Parameters
- $tableRowsToShow : array<string, array<string|int, string>>
-
array of select value => array of IDs of child elements to show
Return values
void —setTransformSingleSelect()
Specifies if select boxes that contain only a single element should be transformed to a simple text field.
public
setTransformSingleSelect(bool $transformSingleSelect) : void
Parameters
- $transformSingleSelect : bool
-
transform single options to text
Return values
void —setTransient()
Specifies that the value should not be automatically saved when used in self-service or server profile (default: false).
public
setTransient(bool $transient) : void
Parameters
- $transient : bool
-
transient field
Return values
void —setWidth()
Specifies the width of this selection box.
public
setWidth(string $width) : void
Parameters
- $width : string
-
width (e.g. 20em)
Return values
void —getDataAttributesAsString()
Returns the data attributes as rendered string.
protected
getDataAttributesAsString() : string
Return values
string —data attributes
getShowHideSelector()
Returns the selector to use to find the show/hide elements.
protected
getShowHideSelector() : string
Tags
Return values
string —selector
printCodeForShowHideTableRows()
Creates the JavaScript code to hide/show table rows based on the select value.
private
printCodeForShowHideTableRows(string &$onChange) : void
Parameters
- $onChange : string
-
onChange code
Return values
void —printOptionsHTML()
Prints the HTML code of the option tags.
private
printOptionsHTML(array<string, string> $elements) : void
Parameters
- $elements : array<string, string>
-
list of options