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

Class: HTML_QuickForm2_Element_Hierselect

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

Class Overview

HTML_Common2
   |
   --HTML_QuickForm2_Node
      |
      --HTML_QuickForm2_Container
         |
         --HTML_QuickForm2_Container_Group
            |
            --HTML_QuickForm2_Element_Hierselect

Hierarchical select element


Author(s):

Version:

  • Release: 2.1.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Container_Group

HTML_QuickForm2_Container_Group::appendChild()
Appends an element to the container
HTML_QuickForm2_Container_Group::getChildValues()
HTML_QuickForm2_Container_Group::getName()
HTML_QuickForm2_Container_Group::getSeparator()
Returns string(s) to separate grouped elements
HTML_QuickForm2_Container_Group::getType()
HTML_QuickForm2_Container_Group::insertBefore()
Inserts an element in the container
HTML_QuickForm2_Container_Group::prependsName()
HTML_QuickForm2_Container_Group::removeChild()
Removes the element from this container
HTML_QuickForm2_Container_Group::renameChild()
Prepends group's name to contained element's name
HTML_QuickForm2_Container_Group::render()
Renders the group using the given renderer
HTML_QuickForm2_Container_Group::setName()
HTML_QuickForm2_Container_Group::setSeparator()
Sets string(s) to separate grouped elements
HTML_QuickForm2_Container_Group::setValue()
HTML_QuickForm2_Container_Group::__toString()

Class: HTML_QuickForm2_Container

HTML_QuickForm2_Container::addElement()
Appends an element to the container (possibly creating it first)
HTML_QuickForm2_Container::appendChild()
Appends an element to the container
HTML_QuickForm2_Container::arrayMerge()
Merges two arrays
HTML_QuickForm2_Container::count()
Returns the number of elements in the container
HTML_QuickForm2_Container::getChildValues()
Returns the array containing child elements' values
HTML_QuickForm2_Container::getElementById()
Returns an element if its id is found
HTML_QuickForm2_Container::getElements()
Returns an array of this container's elements
HTML_QuickForm2_Container::getElementsByName()
Returns an array of elements which name corresponds to element
HTML_QuickForm2_Container::getIterator()
Returns a recursive iterator for the container elements
HTML_QuickForm2_Container::getJavascriptTriggers()
HTML_QuickForm2_Container::getJavascriptValue()
Returns Javascript code for getting the element's value
HTML_QuickForm2_Container::getRawValue()
Returns the container's value without filters applied
HTML_QuickForm2_Container::getRecursiveIterator()
Returns a recursive iterator iterator for the container elements
HTML_QuickForm2_Container::getValue()
Returns the container's value, possibly with filters applied
HTML_QuickForm2_Container::insertBefore()
Inserts an element in the container
HTML_QuickForm2_Container::persistentFreeze()
HTML_QuickForm2_Container::prependsName()
Whether container prepends its name to names of contained elements
HTML_QuickForm2_Container::removeChild()
Removes the element from this container
HTML_QuickForm2_Container::render()
Renders the container using the given renderer
HTML_QuickForm2_Container::setName()
HTML_QuickForm2_Container::toggleFrozen()
HTML_QuickForm2_Container::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Container::validate()
Performs the server-side validation
HTML_QuickForm2_Container::__call()
Appends an element to the container, creating it first
HTML_QuickForm2_Container::__toString()

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 56]
Hierarchical select element

Class to dynamically create two or more HTML Select elements The first select changes the content of the second select and so on. This element is considered as a group. Selects will be named groupName[0], groupName[1], groupName[2]...



[ Top ]


Class Variables

$callback =  null

[line 72]

PHP callback function for getting additional options

Type:   callback


[ Top ]

$jsCallback =  null

[line 80]

Javascript callback function for getting additional options

Type:   string


[ Top ]

$options = array()

[line 64]

Options for all the select elements

Type:   array


[ Top ]

$size =  0

[line 86]

Number of select elements in hierselect
  • Access: protected

Type:   int


[ Top ]



Method Detail

__construct (Constructor)   [line 115]

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

Class constructor

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

  • 'options': data to populate child elements' options with. Passed to loadOptions() method.
  • 'size': number of selects in hierselect. If not given will be set from size of options array or size of array passed to setValue()
$data is propagated to created Select elements with these keys removed.

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

getType   [line 96]

void getType( )

  • Access: public

Overrides HTML_QuickForm2_Container_Group::getType() (parent method not documented)
[ Top ]

loadOptions   [line 172]

$this loadOptions( array $options, [callback $callback = null], [string $jsCallback = null])

Initializes the the options for each select element.

Format is a bit more complex than for a simple select as we need to know which options are related to the ones in the previous select:

Ex:

  1.  // first select
  2.  $select1[0'Pop';
  3.  $select1[1'Classical';
  4.  $select1[2'Funeral doom';
  5.  
  6.  // second select
  7.  $select2[0][0'Red Hot Chilly Peppers';
  8.  $select2[0][1'The Pixies';
  9.  $select2[1][0'Wagner';
  10.  $select2[1][1'Strauss';
  11.  $select2[2][0'Pantheist';
  12.  $select2[2][1'Skepticism';
  13.  
  14.  // Two selects
  15.  $sel $form->addElement('hierselect''cds')->setLabel('Choose CD:');
  16.  $sel->loadOptions(array($select1$select2));
  17.  
  18.  // If you have a third select with prices for the cds
  19.  $select3[0][0][0'15.00$';
  20.  $select3[0][0][1'17.00$';
  21.  // etc
  22.  
  23.  // You can now use
  24.  $sel $form->addElement('hierselect''cds')->setLabel('Choose CD:');
  25.  $sel->loadOptions(array($select1$select2$select3));

  • Throws: HTML_QuickForm2_InvalidArgumentException
  • Access: public

Parameters:

array   $options   —  Array of options defining each element
callback   $callback   —  Callback function to load additional options. It will receive an array of keys and should return associative array ('option value' => 'option text')
string   $jsCallback   —  Javascript function to load additional options (presumably via some sort of AJAX request). It will receive an array of keys and should return {'values': [...], 'texts': [...]}

[ Top ]

render   [line 379]

HTML_QuickForm2_Renderer render( HTML_QuickForm2_Renderer $renderer)

Renders the hierselect using the given renderer
  • Throws: HTML_QuickForm2_Exception if number of selects in hierselect cannot be determined
  • Access: public

Overrides HTML_QuickForm2_Container_Group::render() (Renders the group using the given renderer)

Parameters:

HTML_QuickForm2_Renderer   $renderer   — 

[ Top ]

setName   [line 270]

$this setName( string $name)

Sets the element's name

Need to override group's implementation due to overridden updateValue()

  • Access: public

Overrides HTML_QuickForm2_Container_Group::setName() (parent method not documented)

Parameters:

string   $name   — 

[ Top ]

setValue   [line 249]

$this setValue( array $value)

Sets the element's value

This also creates missing selects and loads their options, in addition to HTML_QuickForm2_Container_Group::setValue() behaviour

  • Access: public

Overrides HTML_QuickForm2_Container_Group::setValue() (parent method not documented)

Parameters:

array   $value   — 

[ Top ]

updateValue   [line 284]

void updateValue( )

Called when the element needs to update its value from form's data sources

Hierselect uses the Element's implementation of updateValue() since its values need to be passed through setValue() to properly update options of its child selects.

  • Access: protected

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


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