CWIS Developer Documentation
|
Convenience class for generating an HTML select/option form element. More...
Public Member Functions | |
__construct ($ResultVar, $Options, $SelectedValue=NULL) | |
Class constructor. More... | |
PrintHtml () | |
Print HTML for list. More... | |
GetHtml () | |
Get HTML for list. More... | |
DisabledOptions ($Options=NULL) | |
Get/set disabled options. More... | |
SelectedValue ($NewValue=NULL) | |
Get/set currently selected value or array of currently selected values. More... | |
Size ($NewValue=NULL) | |
Get/set the list size (number of visible items). More... | |
MultipleAllowed ($NewValue=NULL) | |
Get/set whether multiple items may be selected. More... | |
SubmitOnChange ($NewValue=NULL) | |
Get/set whether to submit the form when the list value is changed. More... | |
OnChangeAction ($NewValue=NULL) | |
Get/set action to take if form is submitted on change. More... | |
PrintIfEmpty ($NewValue=NULL) | |
Get/set whether list should be output even if there are no items. More... | |
Disabled ($NewValue=NULL) | |
Get/set whether the whole option list is editable. More... | |
ClassForList ($NewValue=NULL) | |
Get/set CSS class(es) for the list. More... | |
ClassForOptions ($NewValue=NULL) | |
Get/set CSS class(es) for the options. More... | |
DataForOptions ($NewValue=NULL) | |
Get/set HTML data attributes for the options. More... | |
MaxLabelLength ($NewValue=NULL) | |
Get/set the maximum number of character a label will be displayed. More... | |
AddAttribute ($Name, $Value) | |
Add an attribute for the <select> tag for the list. More... | |
Protected Member Functions | |
GetOptionTag ($Value, $Label) | |
Get HTML for one option. More... | |
GetSelectOpenTag () | |
Get HTML for tag to begin list. More... | |
Protected Attributes | |
$AdditionalAttributes = array() | |
$Disabled = FALSE | |
$DisabledOptions = array() | |
$ListClasses = NULL | |
$MaxLabelLength = 0 | |
$MultipleAllowed = FALSE | |
$OnChangeAction = "submit()" | |
$Options | |
$OptionClasses = NULL | |
$OptionData = array() | |
$PrintIfEmpty = TRUE | |
$ResultVar | |
$SelectedValue | |
$Size = 1 | |
$SubmitOnChange = FALSE | |
Convenience class for generating an HTML select/option form element.
Definition at line 13 of file HtmlOptionList.php.
HtmlOptionList::__construct | ( | $ResultVar, | |
$Options, | |||
$SelectedValue = NULL |
|||
) |
Class constructor.
string | $ResultVar | Name of form variable for select element. |
array | $Options | Array of options, with form values for the array index and labels for the array values. For grouping, any of the options may actually be an array of options, with a group label for the index, and the array for the value. |
mixed | $SelectedValue | Currently selected form value or array of currently selected form values. (OPTIONAL) |
Definition at line 28 of file HtmlOptionList.php.
References $Options, $ResultVar, $SelectedValue, and SelectedValue().
HtmlOptionList::AddAttribute | ( | $Name, | |
$Value | |||
) |
Add an attribute for the <select> tag for the list.
If this is called multiple times for the same attribute name, only the value from the last call will be used.
string | $Name | Attribute name. |
string | $Value | Attribute value (should not be escaped). |
Definition at line 318 of file HtmlOptionList.php.
HtmlOptionList::ClassForList | ( | $NewValue = NULL | ) |
Get/set CSS class(es) for the list.
string | $NewValue | String with class names, separated by spaces. |
Definition at line 248 of file HtmlOptionList.php.
References $ListClasses.
HtmlOptionList::ClassForOptions | ( | $NewValue = NULL | ) |
Get/set CSS class(es) for the options.
If separate classes per option are supplied as an array, they do not have to be in the same order as the options originally supplied to the constructor, and not all options must be included.
mixed | $NewValue | String with class names, separated by spaces, or array of class name strings, indexed by option value. |
Definition at line 268 of file HtmlOptionList.php.
References $OptionClasses.
HtmlOptionList::DataForOptions | ( | $NewValue = NULL | ) |
Get/set HTML data attributes for the options.
array | $NewValue | Two-dimensional array of data attribute values, first dimension keyed by option value, second keyed by data attribute name (e.g., 'field-id' for a 'data-field-id' attribute). |
Definition at line 285 of file HtmlOptionList.php.
References $OptionData.
HtmlOptionList::Disabled | ( | $NewValue = NULL | ) |
Get/set whether the whole option list is editable.
NOTE: When the list is not editable, values for it are not submitted with the form. This is distinct from whether individual options are disabled.
bool | $NewValue | If TRUE, list is not editable. |
Definition at line 234 of file HtmlOptionList.php.
References $Disabled.
Referenced by GetSelectOpenTag().
HtmlOptionList::DisabledOptions | ( | $Options = NULL | ) |
Get/set disabled options.
mixed | $Options | Option or array of options to disable. If a single option then it should be the value and will be added to any existing disabled options, and if an array it should have the values for the index and will replace the current list of disabled options. (OPTIONAL) |
Definition at line 100 of file HtmlOptionList.php.
References $DisabledOptions, and $Options.
Referenced by GetOptionTag().
HtmlOptionList::GetHtml | ( | ) |
Get HTML for list.
Definition at line 47 of file HtmlOptionList.php.
References GetOptionTag(), GetSelectOpenTag(), and PrintIfEmpty().
Referenced by PrintHtml().
|
protected |
Get HTML for one option.
string | $Value | Value for option. |
string | $Label | Label for option. |
Definition at line 347 of file HtmlOptionList.php.
References DisabledOptions(), MaxLabelLength(), and SelectedValue().
Referenced by GetHtml().
|
protected |
Get HTML for tag to begin list.
Definition at line 410 of file HtmlOptionList.php.
References Disabled(), MultipleAllowed(), OnChangeAction(), Size(), and SubmitOnChange().
Referenced by GetHtml().
HtmlOptionList::MaxLabelLength | ( | $NewValue = NULL | ) |
Get/set the maximum number of character a label will be displayed.
If a label exceeds the limit, the extra characters will be taken off.
int | $NewValue | Maximum number of characters a label will be displayed (OPTIONAL, defaults to no limit). If zero is passed in, limit will be reset to none. |
Definition at line 302 of file HtmlOptionList.php.
References $MaxLabelLength.
Referenced by GetOptionTag().
HtmlOptionList::MultipleAllowed | ( | $NewValue = NULL | ) |
Get/set whether multiple items may be selected.
Defaults to FALSE.
bool | $NewValue | If TRUE, users will be able to select multiple items. (OPTIONAL) |
Definition at line 151 of file HtmlOptionList.php.
References $MultipleAllowed.
Referenced by GetSelectOpenTag().
HtmlOptionList::OnChangeAction | ( | $NewValue = NULL | ) |
Get/set action to take if form is submitted on change.
Defaults to "submit()" (without the quotes). No character escaping or other processing is done to this value before it is added to the HTML, so whatever is passed in must be pre-sanitized if needed, including escaping any double quotation marks. This setting has no effect if SubmitOnChange() is set to FALSE.
string | $NewValue | New action. (OPTIONAL) |
Definition at line 200 of file HtmlOptionList.php.
References $OnChangeAction.
Referenced by GetSelectOpenTag().
HtmlOptionList::PrintHtml | ( | ) |
HtmlOptionList::PrintIfEmpty | ( | $NewValue = NULL | ) |
Get/set whether list should be output even if there are no items.
If this is set to FALSE and there are no items in the list, GetHtml() will return an empty string and PrintHtml() will print nothing. Defaults to TRUE.
bool | $NewValue | If TRUE, HTML will be returned/printed even if there are no items in the list. (OPTIONAL) |
Definition at line 218 of file HtmlOptionList.php.
References $PrintIfEmpty.
Referenced by GetHtml().
HtmlOptionList::SelectedValue | ( | $NewValue = NULL | ) |
Get/set currently selected value or array of currently selected values.
mixed | $NewValue | Currently selected form value or array of currently selected form values. (OPTIONAL) |
Definition at line 122 of file HtmlOptionList.php.
References $SelectedValue.
Referenced by __construct(), and GetOptionTag().
HtmlOptionList::Size | ( | $NewValue = NULL | ) |
Get/set the list size (number of visible items).
Defaults to 1.
int | $NewValue | Current size. (OPTIONAL) |
Definition at line 136 of file HtmlOptionList.php.
References $Size.
Referenced by GetSelectOpenTag().
HtmlOptionList::SubmitOnChange | ( | $NewValue = NULL | ) |
Get/set whether to submit the form when the list value is changed.
Defaults to FALSE.
bool | $NewValue | If TRUE, form will be submitted on change. (OPTIONAL) |
Definition at line 180 of file HtmlOptionList.php.
References $SubmitOnChange.
Referenced by GetSelectOpenTag().
|
protected |
Definition at line 326 of file HtmlOptionList.php.
|
protected |
Definition at line 327 of file HtmlOptionList.php.
Referenced by Disabled().
|
protected |
Definition at line 328 of file HtmlOptionList.php.
Referenced by DisabledOptions().
|
protected |
Definition at line 329 of file HtmlOptionList.php.
Referenced by ClassForList().
|
protected |
Definition at line 330 of file HtmlOptionList.php.
Referenced by MaxLabelLength().
|
protected |
Definition at line 331 of file HtmlOptionList.php.
Referenced by MultipleAllowed().
|
protected |
Definition at line 332 of file HtmlOptionList.php.
Referenced by OnChangeAction().
|
protected |
Definition at line 334 of file HtmlOptionList.php.
Referenced by ClassForOptions().
|
protected |
Definition at line 335 of file HtmlOptionList.php.
Referenced by DataForOptions().
|
protected |
Definition at line 333 of file HtmlOptionList.php.
Referenced by __construct(), and DisabledOptions().
|
protected |
Definition at line 336 of file HtmlOptionList.php.
Referenced by PrintIfEmpty().
|
protected |
Definition at line 337 of file HtmlOptionList.php.
Referenced by __construct().
|
protected |
Definition at line 338 of file HtmlOptionList.php.
Referenced by __construct(), and SelectedValue().
|
protected |
Definition at line 339 of file HtmlOptionList.php.
Referenced by Size().
|
protected |
Definition at line 340 of file HtmlOptionList.php.
Referenced by SubmitOnChange().