CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HtmlOptionList Class Reference

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...

## Protected Member Functions
| GetOptionTag ($Value, $Label)
| Get HTML for one option. More...

## Protected Attributes
| $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

## Detailed Description

Convenience class for generating an HTML select/option form element.

Definition at line 13 of file HtmlOptionList.php.

## Constructor & Destructor Documentation

HtmlOptionList::__construct | ( |  | $ResultVar,
|  |  | $Options,
|  |  | $SelectedValue = `NULL`
| ) |  |

Class constructor.

Parameters

  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().

## Member Function Documentation

HtmlOptionList::ClassForList | ( |  | $NewValue = `NULL` | ) |

Get/set CSS class(es) for the list.

Parameters

  string | $NewValue | String with class names, separated by spaces.

Returns
  string Current classes, or NULL if no classes have been set.

Definition at line 264 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.

Parameters

  mixed | $NewValue | String with class names, separated by spaces, or array of class name strings, indexed by option value.

Returns
  mixed String with class names, separated by spaces, or array of class name strings, indexed by option value, or NULL if no option classes have been set.

Definition at line 284 of file HtmlOptionList.php.

References $OptionClasses.

HtmlOptionList::DataForOptions | ( |  | $NewValue = `NULL` | ) |

Get/set HTML data attributes for the options.

Parameters

  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).

Returns
  Array of current data attributes (empty if none currently set).

Definition at line 301 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.

Parameters

  bool | $NewValue | If TRUE, list is not editable.

Returns
  bool TRUE if list will not be editabled, otherwise FALSE.

Definition at line 250 of file HtmlOptionList.php.

References $Disabled.

Referenced by GetHtml().

Here is the caller graph for this function:

HtmlOptionList::DisabledOptions | ( |  | $Options = `NULL` | ) |

Get/set disabled options.

Parameters

  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 116 of file HtmlOptionList.php.

References $DisabledOptions, and $Options.

Referenced by GetOptionTag().

Here is the caller graph for this function:

HtmlOptionList::GetHtml | ( |  | ) |

Get HTML for list.

Returns
  string Generated HTML.

Definition at line 47 of file HtmlOptionList.php.

References Disabled(), GetOptionTag(), MultipleAllowed(), OnChangeAction(), PrintIfEmpty(), Size(), and SubmitOnChange().

Referenced by PrintHtml().

Here is the caller graph for this function:

HtmlOptionList::GetOptionTag | ( |  | $Value,
|  |  | $Label
| ) |  |
| protected

Get HTML for one option.

Parameters

  string | $Value | Value for option.
  string | $Label | Label for option.

Definition at line 349 of file HtmlOptionList.php.

References DisabledOptions(), MaxLabelLength(), and SelectedValue().

Referenced by GetHtml().

Here is the caller graph for this function:

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.

Parameters

  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.

Returns
  Current maximum label length, or zero if there is no limit.

Definition at line 318 of file HtmlOptionList.php.

References $MaxLabelLength.

Referenced by GetOptionTag().

Here is the caller graph for this function:

HtmlOptionList::MultipleAllowed | ( |  | $NewValue = `NULL` | ) |

Get/set whether multiple items may be selected.

Defaults to FALSE.

Parameters

  bool | $NewValue | If TRUE, users will be able to select multiple items. (OPTIONAL)

Returns
  bool TRUE if users can select multiple items, otherwise FALSE.

Definition at line 167 of file HtmlOptionList.php.

References $MultipleAllowed.

Referenced by GetHtml().

Here is the caller graph for this function:

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.

Parameters

  string | $NewValue | New action. (OPTIONAL)

Returns
  string Current action.

See also
  HtmlOptionList::SubmitOnChange()

Definition at line 216 of file HtmlOptionList.php.

References $OnChangeAction.

Referenced by GetHtml().

Here is the caller graph for this function:

HtmlOptionList::PrintHtml | ( |  | ) |

Print HTML for list.

Definition at line 38 of file HtmlOptionList.php.

References GetHtml().

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.

Parameters

  bool | $NewValue | If TRUE, HTML will be returned/printed even if there are no items in the list. (OPTIONAL)

Returns
  bool TRUE if empty list will be printed, otherwise FALSE.

Definition at line 234 of file HtmlOptionList.php.

References $PrintIfEmpty.

Referenced by GetHtml().

Here is the caller graph for this function:

HtmlOptionList::SelectedValue | ( |  | $NewValue = `NULL` | ) |

Get/set currently selected value or array of currently selected values.

Parameters

  mixed | $NewValue | Currently selected form value or array of currently selected form values. (OPTIONAL)

Returns
  mixed Selected value or array of currently selected values.

Definition at line 138 of file HtmlOptionList.php.

References $SelectedValue.

Referenced by __construct(), and GetOptionTag().

Here is the caller graph for this function:

HtmlOptionList::Size | ( |  | $NewValue = `NULL` | ) |

Get/set the list size (number of visible items).

Defaults to 1.

Parameters

  int | $NewValue | Current size. (OPTIONAL)

Returns
  int Current size.

Definition at line 152 of file HtmlOptionList.php.

References $Size.

Referenced by GetHtml().

Here is the caller graph for this function:

HtmlOptionList::SubmitOnChange | ( |  | $NewValue = `NULL` | ) |

Get/set whether to submit the form when the list value is changed.

Defaults to FALSE.

Parameters

  bool | $NewValue | If TRUE, form will be submitted on change. (OPTIONAL)

Returns
  bool TRUE if form will be submitted, otherwise FALSE.

See also
  HtmlOptionList::OnChangeAction()

Definition at line 196 of file HtmlOptionList.php.

References $SubmitOnChange.

Referenced by GetHtml().

Here is the caller graph for this function:

## Member Data Documentation

HtmlOptionList::$Disabled = FALSE
| protected

Definition at line 329 of file HtmlOptionList.php.

Referenced by Disabled().

HtmlOptionList::$DisabledOptions = array()
| protected

Definition at line 330 of file HtmlOptionList.php.

Referenced by DisabledOptions().

HtmlOptionList::$ListClasses = NULL
| protected

Definition at line 331 of file HtmlOptionList.php.

Referenced by ClassForList().

HtmlOptionList::$MaxLabelLength = 0
| protected

Definition at line 332 of file HtmlOptionList.php.

Referenced by MaxLabelLength().

HtmlOptionList::$MultipleAllowed = FALSE
| protected

Definition at line 333 of file HtmlOptionList.php.

Referenced by MultipleAllowed().

HtmlOptionList::$OnChangeAction = "submit()"
| protected

Definition at line 334 of file HtmlOptionList.php.

Referenced by OnChangeAction().

HtmlOptionList::$OptionClasses = NULL
| protected

Definition at line 336 of file HtmlOptionList.php.

Referenced by ClassForOptions().

HtmlOptionList::$OptionData = array()
| protected

Definition at line 337 of file HtmlOptionList.php.

Referenced by DataForOptions().

HtmlOptionList::$Options
| protected

Definition at line 335 of file HtmlOptionList.php.

Referenced by __construct(), and DisabledOptions().

HtmlOptionList::$PrintIfEmpty = TRUE
| protected

Definition at line 338 of file HtmlOptionList.php.

Referenced by PrintIfEmpty().

HtmlOptionList::$ResultVar
| protected

Definition at line 339 of file HtmlOptionList.php.

Referenced by __construct().

HtmlOptionList::$SelectedValue
| protected

Definition at line 340 of file HtmlOptionList.php.

Referenced by __construct(), and SelectedValue().

HtmlOptionList::$Size = 1
| protected

Definition at line 341 of file HtmlOptionList.php.

Referenced by Size().

HtmlOptionList::$SubmitOnChange = FALSE
| protected

Definition at line 342 of file HtmlOptionList.php.

Referenced by SubmitOnChange().

The documentation for this class was generated from the following file:

- lib/ScoutLib/HtmlOptionList.php