HTML_QuickForm2
[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_Element_Select

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Element/Select.php

Class Overview

HTML_Common2
   |
   --HTML_QuickForm2_Node
      |
      --HTML_QuickForm2_Element
         |
         --HTML_QuickForm2_Element_Select

Class representing a <select> element


Author(s):

Version:

  • Release: 2.1.0

Variables

Methods


Child classes:

HTML_QuickForm2_Element_DualSelect
"Dualselect" element

Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Element

HTML_QuickForm2_Element::applyFilters()
Applies recursive and non-recursive filters on element value
HTML_QuickForm2_Element::getJavascriptTriggers()
HTML_QuickForm2_Element::getJavascriptValue()
Returns Javascript code for getting the element's value
HTML_QuickForm2_Element::getPersistentContent()
Generates hidden form field containing the element's value
HTML_QuickForm2_Element::render()
Renders the element using the given renderer
HTML_QuickForm2_Element::setName()
HTML_QuickForm2_Element::updateValue()
Called when the element needs to update its value from form's data sources

Class: HTML_QuickForm2_Node

HTML_QuickForm2_Node::__construct()
Class constructor
HTML_QuickForm2_Node::addFilter()
Adds a filter
HTML_QuickForm2_Node::addRecursiveFilter()
Adds a recursive filter
HTML_QuickForm2_Node::addRule()
Adds a validation rule
HTML_QuickForm2_Node::applyFilter()
Helper function for applying filter callback to a value
HTML_QuickForm2_Node::applyFilters()
Applies non-recursive filters on element value
HTML_QuickForm2_Node::createRule()
Creates a validation rule
HTML_QuickForm2_Node::generateId()
Generates an id for the element
HTML_QuickForm2_Node::getContainer()
Returns the element containing current
HTML_QuickForm2_Node::getData()
Returns the element options
HTML_QuickForm2_Node::getDataSources()
Returns the data sources for this element
HTML_QuickForm2_Node::getError()
Returns the error message for the element
HTML_QuickForm2_Node::getId()
Returns the element's id
HTML_QuickForm2_Node::getJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Node::getJavascriptValue()
Returns Javascript code for getting the element's value
HTML_QuickForm2_Node::getLabel()
Returns the element's label(s)
HTML_QuickForm2_Node::getName()
Returns the element's name
HTML_QuickForm2_Node::getRawValue()
Returns the element's value without filters applied
HTML_QuickForm2_Node::getType()
Returns the element's type
HTML_QuickForm2_Node::getValue()
Returns the element's value, possibly with filters applied
HTML_QuickForm2_Node::isRequired()
Checks whether an element is required
HTML_QuickForm2_Node::onAttributeChange()
Intercepts setting 'name' and 'id' attributes
HTML_QuickForm2_Node::persistentFreeze()
Changes the element's persistent freeze behaviour
HTML_QuickForm2_Node::removeRule()
Removes a validation rule
HTML_QuickForm2_Node::render()
Renders the element using the given renderer
HTML_QuickForm2_Node::renderClientRules()
Adds element's client-side validation rules to a builder object
HTML_QuickForm2_Node::setContainer()
Adds the link to the element containing current
HTML_QuickForm2_Node::setError()
Sets the error message to the element
HTML_QuickForm2_Node::setId()
Sets the element's id
HTML_QuickForm2_Node::setLabel()
Sets the element's label(s)
HTML_QuickForm2_Node::setName()
Sets the element's name
HTML_QuickForm2_Node::setValue()
Sets the element's value
HTML_QuickForm2_Node::storeId()
Stores the explicitly given id to prevent duplicate id generation
HTML_QuickForm2_Node::toggleFrozen()
Changes the element's frozen status
HTML_QuickForm2_Node::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Node::validate()
Performs the server-side validation

Class Details

[line 43]
Class representing a <select> element


[ Top ]


Class Variables

$data = array('intrinsic_validation' => true)

[line 73]

Enable intrinsic validation by default
  • Access: protected

Type:   array
Overrides:   Array


[ Top ]

$optionContainer =

[line 67]

Object containing options for the <select> element
  • Access: protected



[ Top ]

$persistent =  true

[line 45]

  • Access: protected

Type:   mixed
Overrides:   Array


[ Top ]

$possibleValues = array()

[line 60]

Possible values for select elements

A value is considered possible if it is present as a value attribute of some option and that option is not disabled.

  • Access: protected

Type:   array


[ Top ]

$values = array()

[line 51]

Values for the select element (i.e. values of the selected options)
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 92]

HTML_QuickForm2_Element_Select __construct( [string $name = null], [string|array $attributes = null], [array $data = array()])

Class constructor

Select element can understand the following keys in $data parameter:

  • 'options': data to populate element's options with. Passed to loadOptions() method.
  • 'intrinsic_validation': setting this to false will disable that validation, getValue() will then return all submit values, not just those corresponding to options present in the element. May be useful in AJAX scenarios.

  • Throws: HTML_QuickForm2_InvalidArgumentException if junk is given in $options
  • Access: public

Overrides HTML_QuickForm2_Node::__construct() (Class constructor)

Parameters:

string   $name   —  Element name
string|array   $attributes   —  Attributes (either a string or an array)
array   $data   —  Additional element data

[ Top ]

addOptgroup   [line 304]

HTML_QuickForm2_Element_Select_Optgroup addOptgroup( string $label, [string|array $attributes = null])

Adds a new optgroup
  • Access: public

Parameters:

string   $label   —  'label' attribute for optgroup tag
string|array   $attributes   —  Additional attributes for <optgroup> tag (either as a string or as an associative array)

[ Top ]

addOption   [line 290]

void addOption( string $text, string $value, [string|array $attributes = null])

Adds a new option

Please note that if you pass 'selected' attribute in the $attributes parameter then this option's value will be added to <select>'s values.

  • Access: public

Parameters:

string   $text   —  Option text
string   $value   —  'value' attribute for <option> tag
string|array   $attributes   —  Additional attributes for <option> tag (either as a string or as an associative array)

[ Top ]

getFrozenHtml   [line 125]

void getFrozenHtml( )

  • Access: protected

[ Top ]

getOptionContainer   [line 333]

HTML_QuickForm2_Element_Select_OptionContainer getOptionContainer( )

Get the select's option container, e.g. for rendering purposes.
  • Access: public

[ Top ]

getRawValue   [line 172]

mixed getRawValue( )

Returns the value of the <select> element

Please note that the returned value may not necessarily be equal to that passed to setValue(). It passes "intrinsic validation" confirming that such value could possibly be submitted by this <select> element. Specifically, this method will return null if the elements "disabled" attribute is set, it will not return values if there are no options having such a "value" attribute or if such options' "disabled" attribute is set. It will also only return a scalar value for single selects, mimicking the common browsers' behaviour.

  • Return: "value" attribute of selected option in case of single select, array of selected options' "value" attributes in case of multiple selects, null if no options selected
  • Access: public

Overrides HTML_QuickForm2_Node::getRawValue() (Returns the element's value without filters applied)
[ Top ]

getType   [line 100]

void getType( )

  • Access: public

Overrides HTML_QuickForm2_Node::getType() (Returns the element's type)
[ Top ]

loadOptions   [line 247]

$this loadOptions( array $options)

Loads <option>s (and <optgroup>s) for select element

The method expects a array of options and optgroups:

 array(
     'option value 1' => 'option text 1',
     ...
     'option value N' => 'option text N',
     'optgroup label 1' => array(
         'option value' => 'option text',
         ...
     ),
     ...
 )
If value is a scalar, then array key is treated as "value" attribute of <option> and value as this <option>'s text. If value is an array, then key is treated as a "label" attribute of <optgroup> and value as an array of <option>s for this <optgroup>.

If you need to specify additional attributes for <option> and <optgroup> tags, then you need to use addOption() and addOptgroup() methods instead of this one.

  • Throws: HTML_QuickForm2_InvalidArgumentException if junk is given in $options
  • Access: public

Parameters:

array   $options   — 

[ Top ]

loadOptionsFromArray   [line 265]

void loadOptionsFromArray( HTML_QuickForm2_Element_Select_OptionContainer $container, array $options)

Adds options from given array into given container
  • Access: protected

Parameters:

HTML_QuickForm2_Element_Select_OptionContainer   $container   —  options will be added to this container
array   $options   —  options array

[ Top ]

setValue   [line 207]

void setValue( $value)

  • Access: public

Overrides HTML_QuickForm2_Node::setValue() (Sets the element's value)

Parameters:

   $value   — 

[ Top ]

updateValue   [line 309]

void updateValue( )

  • Access: protected

Overrides HTML_QuickForm2_Element::updateValue() (Called when the element needs to update its value from form's data sources)
[ Top ]

__toString   [line 105]

void __toString( )

  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Element_DualSelect::__toString()

[ Top ]


Documentation generated on Wed, 10 Apr 2019 08:56:11 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.