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

Class: HTML_QuickForm2_Node

Source Location: /HTML_QuickForm2-2.0.0beta1/HTML/QuickForm2/Node.php

Class Overview

HTML_Common2
   |
   --HTML_QuickForm2_Node

Abstract base class for all QuickForm2 Elements and Containers


Author(s):

Version:

  • Release: 2.0.0beta1

Variables

Methods


Child classes:

HTML_QuickForm2_Container
Abstract base class for simple QuickForm2 containers
HTML_QuickForm2_Element
Abstract base class for simple QuickForm2 elements (not Containers)

Inherited Variables

Inherited Methods


Class Details

[line 94]
Abstract base class for all QuickForm2 Elements and Containers

This class is mostly here to define the interface that should be implemented by the subclasses. It also contains static methods handling generation of unique ids for elements which do not have ids explicitly set.



[ Top ]


Class Variables

$container =  null

[line 118]

Element containing current
  • Access: protected



[ Top ]

$data = array()

[line 124]

Contains options and data used for the element creation
  • Access: protected

Type:   array


[ Top ]

$error =  null

[line 152]

Error message (usually set via Rule if validation fails)
  • Access: protected

Type:   string


[ Top ]

$filters = array()

[line 136]

An array of callback filters for element
  • Access: protected

Type:   array


[ Top ]

$frozen =  false

[line 106]

Element's "frozen" status
  • Access: protected

Type:   boolean


[ Top ]

$ids = array()

[line 100]

Array containing the parts of element ids
  • Access: protected

Type:   array


[ Top ]

$persistent =  false

[line 112]

Whether element's value should persist when element is frozen
  • Access: protected

Type:   boolean


[ Top ]

$recursiveFilters = array()

[line 146]

Recursive filter callbacks for element

These are recursively applied for array values of element or propagated to contained elements if the element is a Container

  • Access: protected

Type:   array


[ Top ]

$rules = array()

[line 130]

Validation rules for element
  • Access: protected

Type:   array


[ Top ]

$watchedAttributes = array('id', 'name')

[line 158]

Changing 'name' and 'id' attributes requires some special handling
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 201]

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

Class constructor
  • Access: public

Overridden in child classes as:

HTML_QuickForm2::__construct()
Class constructor, form's "id" and "method" attributes can only be set here
HTML_QuickForm2_Element_Hierselect::__construct()
Class constructor
HTML_QuickForm2_Element_Date::__construct()
Class constructor
HTML_QuickForm2_Element_Static::__construct()
Class constructor
HTML_QuickForm2_Element_Select::__construct()
Class constructor
HTML_QuickForm2_Element_InputFile::__construct()
Class constructor
HTML_QuickForm2_Element_InputCheckable::__construct()
HTML_QuickForm2_Element_InputCheckbox::__construct()

Parameters:

string   $name   —  Element name
string|array   $attributes   —  HTML attributes (either a string or an array)
array   $data   —  Element data (label, options used for element setup)

[ Top ]

addFilter   [line 719]

HTML_QuickForm2_Node addFilter( callback $callback, [array $options = array()])

Adds a filter

A filter is simply a PHP callback which will be applied to the element value when getValue() is called.

  • Return: The element
  • Throws: HTML_QuickForm2_InvalidArgumentException If callback is incorrect
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Element_InputFile::addFilter()

Parameters:

callback   $callback   —  The PHP callback used for filter
array   $options   —  Optional arguments for the callback. The first parameter will always be the element value, then these options will be used as parameters for the callback.

[ Top ]

addRecursiveFilter   [line 750]

HTML_QuickForm2_Node addRecursiveFilter( callback $callback, [array $options = array()])

Adds a recursive filter

A filter is simply a PHP callback which will be applied to the element value when getValue() is called. If the element value is an array, for example with selects of type 'multiple', the filter is applied to all values recursively. A filter on a container will not be applied on a container value but propagated to all contained elements instead.

If the element is not a container and its value is not an array the behaviour will be identical to filters added via addFilter().

  • Return: The element
  • Throws: HTML_QuickForm2_InvalidArgumentException If callback is incorrect
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Element_InputFile::addRecursiveFilter()

Parameters:

callback   $callback   —  The PHP callback used for filter
array   $options   —  Optional arguments for the callback. The first parameter will always be the element value, then these options will be used as parameters for the callback.

[ Top ]

addRule   [line 544]

HTML_QuickForm2_Rule addRule( HTML_QuickForm2_Rule|string $rule, [string|int $messageOrRunAt = ''], [mixed $options = null], [int $runAt = HTML_QuickForm2_Rule::SERVER])

Adds a validation rule
  • Return: The added rule
  • Throws: HTML_QuickForm2_NotFoundException if class for a given rule name cannot be found
  • Throws: HTML_QuickForm2_InvalidArgumentException if $rule is of a wrong type or rule name isn't registered with Factory
  • Access: public

Parameters:

HTML_QuickForm2_Rule|string   $rule   —  Validation rule or rule type
string|int   $messageOrRunAt   —  If first parameter is rule type, then message to display if validation fails, otherwise constant showing whether to perfom validation client-side and/or server-side
mixed   $options   —  Configuration data for the rule
int   $runAt   —  Whether to perfom validation server-side and/or client side. Combination of HTML_QuickForm2_Rule::SERVER and HTML_QuickForm2_Rule::CLIENT constants

[ Top ]

applyFilter   [line 770]

void applyFilter( mixed &$value, mixed $key, array $filter)

Helper function for applying filter callback to a value
  • Access: protected

Parameters:

mixed   &$value   —  Value being filtered
mixed   $key   —  Array key (not used, present to be able to use this method as a callback to array_walk_recursive())
array   $filter   —  Array containing callback and additional callback parameters

[ Top ]

applyFilters   [line 784]

mixed applyFilters( mixed $value)

Applies non-recursive filters on element value
  • Return: Filtered value
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Element::applyFilters()
Applies recursive and non-recursive filters on element value

Parameters:

mixed   $value   —  Element value

[ Top ]

createRule   [line 605]

HTML_QuickForm2_Rule createRule( string $type, [string $message = ''], [mixed $options = null])

Creates a validation rule

This method is mostly useful when when chaining several rules together via HTML_QuickForm2_Rule::and_() and HTML_QuickForm2_Rule::or_() methods:

  1.  $first->addRule('nonempty''Fill in either first or second field')
  2.      ->or_($second->createRule('nonempty'));

  • Return: The created rule
  • Throws: HTML_QuickForm2_NotFoundException If class for the rule can't be found and/or loaded from file
  • Throws: HTML_QuickForm2_InvalidArgumentException If rule type is unknown
  • Access: public

Parameters:

string   $type   —  Rule type
string   $message   —  Message to display if validation fails
mixed   $options   —  Configuration data for the rule

[ Top ]

generateId   [line 224]

string generateId( string $elementName)

Generates an id for the element

Called when an element is created without explicitly given id

  • Return: The generated element id
  • Access: protected

Parameters:

string   $elementName   —  Element name

[ Top ]

getContainer   [line 502]

HTML_QuickForm2_Container|null getContainer( )

Returns the element containing current
  • Access: public

[ Top ]

getData   [line 291]

array getData( )

Returns the element options
  • Access: public

[ Top ]

getDataSources   [line 512]

array getDataSources( )

Returns the data sources for this element
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2::getDataSources()
Returns the list of data sources attached to the form

[ Top ]

getError   [line 680]

string getError( )

Returns the error message for the element
  • Access: public

[ Top ]

getId   [line 331]

string getId( )

Returns the element's id
  • Access: public

[ Top ]

getJavascriptTriggers   [line 703]

array getJavascriptTriggers( )

Returns IDs of form fields that should trigger "live" Javascript validation

Rules added to this element with parameter HTML_QuickForm2_Rule::ONBLUR_CLIENT will be run by after these form elements change or lose focus

  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::getJavascriptTriggers()
HTML_QuickForm2_Element::getJavascriptTriggers()
HTML_QuickForm2_Element_Static::getJavascriptTriggers()
HTML_QuickForm2_Element_DualSelect::getJavascriptTriggers()

[ Top ]

getJavascriptValue   [line 693]

string getJavascriptValue( [bool $inContainer = false])

Returns Javascript code for getting the element's value
  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::getJavascriptValue()
Returns Javascript code for getting the element's value
HTML_QuickForm2_Element::getJavascriptValue()
Returns Javascript code for getting the element's value
HTML_QuickForm2_Element_Static::getJavascriptValue()
HTML_QuickForm2_Element_DualSelect::getJavascriptValue()
Returns Javascript code for getting the element's value

Parameters:

bool   $inContainer   —  Whether it should return a parameter for qf.form.getContainerValue()

[ Top ]

getLabel   [line 401]

string|array getLabel( )

Returns the element's label(s)
  • Access: public

[ Top ]

getName   [line 310]

string getName( )

Returns the element's name
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container_Fieldset::getName()
HTML_QuickForm2_Container_Group::getName()

[ Top ]

getRawValue   [line 373]

mixed getRawValue( )

Returns the element's value without filters applied
  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::getRawValue()
Returns the container's value without filters applied
HTML_QuickForm2_Element_Static::getRawValue()
Static elements have no value
HTML_QuickForm2_Element_Textarea::getRawValue()
HTML_QuickForm2_Element_Select::getRawValue()
Returns the value of the <select> element
HTML_QuickForm2_Element_Input::getRawValue()
HTML_QuickForm2_Element_InputReset::getRawValue()
Reset elements cannot have any submit values
HTML_QuickForm2_Element_InputSubmit::getRawValue()
Returns the element's value
HTML_QuickForm2_Element_InputFile::getRawValue()
Returns the information on uploaded file
HTML_QuickForm2_Element_InputCheckable::getRawValue()
HTML_QuickForm2_Element_InputImage::getRawValue()
Returns the element's value
HTML_QuickForm2_Element_InputButton::getRawValue()
Button elements cannot have any submit values
HTML_QuickForm2_Element_Button::getRawValue()
Returns the element's value

[ Top ]

getType   [line 302]


getValue   [line 380]

mixed getValue( )

Returns the element's value, possibly with filters applied
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::getValue()
Returns the container's value, possibly with filters applied
HTML_QuickForm2_Element_InputFile::getValue()
Alias of getRawValue(), InputFile elements do not allow filters

[ Top ]

isRequired   [line 616]

boolean isRequired( )

Checks whether an element is required
  • Access: public

[ Top ]

onAttributeChange   [line 173]

void onAttributeChange( string $name, [string $value = null])

Intercepts setting 'name' and 'id' attributes

These attributes should always be present and thus trying to remove them will result in an exception. Changing their values is delegated to setName() and setId() methods, respectively

  • Throws: HTML_QuickForm2_InvalidArgumentException if trying to remove a required attribute
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2::onAttributeChange()
HTML_QuickForm2_Element_Static::onAttributeChange()
Intercepts setting 'name' and 'id' attributes
HTML_QuickForm2_Element_DualSelect::onAttributeChange()
HTML_QuickForm2_Element_Input::onAttributeChange()
HTML_QuickForm2_Element_InputCheckable::onAttributeChange()
HTML_QuickForm2_Controller_DefaultAction::onAttributeChange()
Disallow changing the 'id' attribute

Parameters:

string   $name   —  Attribute name
string   $value   —  Attribute value, null if attribute is being removed

[ Top ]

persistentFreeze   [line 455]

bool persistentFreeze( [bool $persistent = null])

Changes the element's persistent freeze behaviour

If persistent freeze is on, the element's value will be kept (and submitted) in a hidden field when the element is frozen.

  • Return: Old value of "persistent freeze" flag
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::persistentFreeze()

Parameters:

bool   $persistent   —  New value for "persistent freeze". If omitted, the method will not set anything, just return the current value of the flag.

[ Top ]

removeRule   [line 574]

HTML_QuickForm2_Rule removeRule( HTML_QuickForm2_Rule $rule)

Removes a validation rule

The method will *not* throw an Exception if the rule wasn't added to the element.

  • Return: Removed rule
  • Access: public

Parameters:

HTML_QuickForm2_Rule   $rule   —  Validation rule to remove

[ Top ]

render   [line 798]

HTML_QuickForm2_Renderer render( HTML_QuickForm2_Renderer $renderer)

Renders the element using the given renderer
  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::render()
Renders the container using the given renderer
HTML_QuickForm2::render()
Renders the form using the given renderer
HTML_QuickForm2_Container_Group::render()
Renders the group using the given renderer
HTML_QuickForm2_Element_Hierselect::render()
Renders the hierselect using the given renderer
HTML_QuickForm2_Element::render()
Renders the element using the given renderer
HTML_QuickForm2_Element_Script::render()
Renders the element as the "hidden" one
HTML_QuickForm2_Element_DualSelect::render()
HTML_QuickForm2_Element_InputHidden::render()
HTML_QuickForm2_Controller_DefaultAction::render()
This element is rendered using renderHidden() method

Parameters:

HTML_QuickForm2_Renderer   $renderer   — 

[ Top ]

renderClientRules   [line 631]

void renderClientRules( HTML_QuickForm2_JavascriptBuilder $builder)

Adds element's client-side validation rules to a builder object
  • Access: protected

Parameters:

HTML_QuickForm2_JavascriptBuilder   $builder   — 

[ Top ]

setContainer   [line 475]

void setContainer( [HTML_QuickForm2_Container $container = null])

Adds the link to the element containing current
  • Throws: HTML_QuickForm2_InvalidArgumentException If trying to set a child of an element as its container
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2::setContainer()

Parameters:

HTML_QuickForm2_Container   $container   —  Element containing the current one, null if the link should really be removed (if removing from container)

[ Top ]

setError   [line 669]

HTML_QuickForm2_Node setError( [string $error = null])

Sets the error message to the element
  • Access: public

Parameters:

string   $error   — 

[ Top ]

setId   [line 350]

HTML_QuickForm2_Node setId( [string $id = null])

Sets the element's id

Please note that elements should always have an id in QuickForm2 and therefore it will not be possible to remove the element's id or set it to an empty value. If id is not explicitly given, it will be autogenerated.

  • Throws: HTML_QuickForm2_InvalidArgumentException if id contains invalid characters (i.e. spaces)
  • Access: public

Overridden in child classes as:

HTML_QuickForm2::setId()

Parameters:

string   $id   —  Element's id, will be autogenerated if not given

[ Top ]

setLabel   [line 417]

HTML_QuickForm2_Node setLabel( string|array $label)

Sets the element's label(s)
  • Access: public

Parameters:

string|array   $label   —  Label for the element (may be an array of labels)

[ Top ]

setName   [line 323]

HTML_QuickForm2_Node setName( string $name)

Sets the element's name
  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::setName()
HTML_QuickForm2_Container_Fieldset::setName()
HTML_QuickForm2_Container_Group::setName()
HTML_QuickForm2_Element::setName()
HTML_QuickForm2_Element_Static::setName()
Sets the element's name

Parameters:

string   $name   — 

[ Top ]

setValue   [line 393]

HTML_QuickForm2_Node setValue( mixed $value)

Sets the element's value
  • Abstract:
  • Access: public

Overridden in child classes as:

HTML_QuickForm2::setValue()
HTML_QuickForm2_Container_Fieldset::setValue()
HTML_QuickForm2_Container_Group::setValue()
HTML_QuickForm2_Element_Hierselect::setValue()
Sets the element's value
HTML_QuickForm2_Element_Date::setValue()
Tries to convert the given value to a usable date before setting the element value
HTML_QuickForm2_Element_Static::setValue()
Static element's content can also be set via this method
HTML_QuickForm2_Element_Textarea::setValue()
HTML_QuickForm2_Element_Select::setValue()
HTML_QuickForm2_Element_Input::setValue()
HTML_QuickForm2_Element_InputReset::setValue()
Reset elements cannot have any submit values
HTML_QuickForm2_Element_InputSubmit::setValue()
Submit's value cannot be set via this method
HTML_QuickForm2_Element_InputFile::setValue()
File upload's value cannot be set here
HTML_QuickForm2_Element_InputCheckable::setValue()
HTML_QuickForm2_Element_InputImage::setValue()
Image button's value cannot be set via this method
HTML_QuickForm2_Element_InputButton::setValue()
Button elements cannot have any submit values
HTML_QuickForm2_Element_Button::setValue()
Button's value cannot be set via this method

Parameters:

mixed   $value   — 

[ Top ]

storeId   [line 271]

void storeId( string $id)

Stores the explicitly given id to prevent duplicate id generation
  • Access: protected

Parameters:

string   $id   —  Element id

[ Top ]

toggleFrozen   [line 433]

bool toggleFrozen( [bool $freeze = null])

Changes the element's frozen status
  • Return: Old value of element's frozen status
  • Access: public

Overridden in child classes as:

HTML_QuickForm2_Container::toggleFrozen()
HTML_QuickForm2_Element_Static::toggleFrozen()
Static element can not be frozen
HTML_QuickForm2_Element_InputHidden::toggleFrozen()
Hidden elements can not be frozen
HTML_QuickForm2_Element_InputReset::toggleFrozen()
Reset buttons can not be frozen
HTML_QuickForm2_Element_InputSubmit::toggleFrozen()
Submit buttons can not be frozen
HTML_QuickForm2_Element_InputFile::toggleFrozen()
File upload elements cannot be frozen
HTML_QuickForm2_Element_InputImage::toggleFrozen()
Image buttons can not be frozen
HTML_QuickForm2_Element_InputButton::toggleFrozen()
Buttons can not be frozen
HTML_QuickForm2_Element_Button::toggleFrozen()
Buttons can not be frozen

Parameters:

bool   $freeze   —  Whether the element should be frozen or editable. If omitted, the method will not change the frozen status, just return its current value

[ Top ]

updateValue   [line 524]

void updateValue( )

Called when the element needs to update its value from form's data sources
  • Abstract:
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Container::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Element_Hierselect::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Element_Date::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Element::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Element_Static::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Element_Select::updateValue()
HTML_QuickForm2_Element_InputSubmit::updateValue()
HTML_QuickForm2_Element_InputFile::updateValue()
HTML_QuickForm2_Element_InputCheckbox::updateValue()
HTML_QuickForm2_Element_InputImage::updateValue()
HTML_QuickForm2_Element_Button::updateValue()

[ Top ]

validate   [line 649]

boolean validate( )

Performs the server-side validation
  • Return: Whether the element is valid
  • Access: protected

Overridden in child classes as:

HTML_QuickForm2_Container::validate()
Performs the server-side validation
HTML_QuickForm2::validate()
Performs the server-side validation
HTML_QuickForm2_Element_InputFile::validate()
Performs the server-side validation

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:47:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright Š PHP Group 2004.