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

Class: HTML_QuickForm2_Element_Select

Source Location: /HTML_QuickForm2-0.2.0/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: 0.2.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Element

HTML_QuickForm2_Element::getId()
HTML_QuickForm2_Element::getName()
HTML_QuickForm2_Element::getPersistentContent()
Generates hidden form field containing the element's value
HTML_QuickForm2_Element::onAttributeChange()
HTML_QuickForm2_Element::setId()
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::addRule()
Adds a validation rule
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::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::getLabel()
Returns the element's label(s)
HTML_QuickForm2_Node::getName()
Returns the element's name
HTML_QuickForm2_Node::getType()
Returns the element's type
HTML_QuickForm2_Node::getValue()
Returns the element's value
HTML_QuickForm2_Node::isRequired()
Checks whether an element is required
HTML_QuickForm2_Node::persistentFreeze()
Changes the element's persistent freeze behaviour
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 elements 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 295]
Class representing a <select> element


[ Top ]


Class Variables

$optionContainer =

[line 319]

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



[ Top ]

$persistent =  true

[line 297]

  • Access: protected

Type:   mixed
Overrides:   Array


[ Top ]

$possibleValues = array()

[line 312]

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 303]

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

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 333]

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

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

Overrides HTML_QuickForm2_Node::__construct() (Class constructor)

Parameters:

string   $name   —  Element name
mixed   $attributes   —  Attributes (either a string or an array)
array   $data   —  Data used to populate the element's options, passed to loadOptions() method. Format:
  1.                    $data = array('options' => array('option1''option2'));

[ Top ]

addOptgroup   [line 542]

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

Adds a new optgroup
  • Access: public

Parameters:

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

[ Top ]

addOption   [line 529]

void addOption( string $text, string $value, [mixed $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
mixed   $attributes   —  Additional attributes for <option> tag (either as a string or as an associative array)

[ Top ]

getFrozenHtml   [line 366]

void getFrozenHtml( )

  • Access: protected

[ Top ]

getType   [line 341]

void getType( )

  • Access: public

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

getValue   [line 413]

mixed getValue( )

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::getValue() (Returns the element's value)
[ Top ]

loadOptions   [line 485]

HTML_QuickForm2_Element_Select 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 503]

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 446]

void setValue( $value)

  • Access: public

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

Parameters:

   $value   — 

[ Top ]

updateValue   [line 547]

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 346]

void __toString( )

  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:10:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.