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

Class: Select

Source Location: /HtmlForm.FormElement.Select.class.php

Class Overview

FormElement
   |
   --Select

Wraps a select.


Author(s):

  • Sebastian Schlapkohl

Version:

  • 1.0

Variables

Methods


Child classes:

SelectList
Constitutes a Select-replacement made of a list of labeled radiobuttons/checkboxes.

Inherited Constants

Inherited Variables

Inherited Methods

Class: FormElement

FormElement::__construct()
General abstract, hidden formelement constructor.
FormElement::addCssClasses()
Adds one or many css-classes to the element's class-attribute.
FormElement::addElement()
Adds a subelement to the element.
FormElement::determineRefiller()
Returns the supposed source of refill values.
FormElement::doRender()
Returns the compiled html-code for the element.
FormElement::getId()
Return the element's html-id.
FormElement::getLabel()
Return the element's label text.
FormElement::getMasterElement()
Return the currently connected owner element for the element.
FormElement::getMasterForm()
Returns the currently connected owner form for the element.
FormElement::getName()
Return the element's html-name.
FormElement::getSubElements()
Return all owned elements of this element.
FormElement::getTitle()
Return the element's html-title.
FormElement::getValidator()
Return the currently connected validator for the element.
FormElement::getValue()
Returns the value of the element if there is any.
FormElement::getValueSet()
Returns the compiled valueset for this element including the elements owned by this one.
FormElement::insertElementAfter()
Searches the subelements of the element if present and inserts a given element after the first found one.
FormElement::isValid()
Answers if the element is in a valid state at the moment.
FormElement::needsUtf8Safety()
Answers if the element needs to be treated with precautions according to possible utf-8 values.
FormElement::printCssClasses()
Compiles the html-class-attribute-string of the element.
FormElement::printDisabled()
Compiles the html-disabled-attribute-string of the element.
FormElement::printId()
Compiles the html-id-attribute-string of the element.
FormElement::printJavascriptEventHandler()
Compiles html-javascript-eventhandler-string of the element.
FormElement::printJavascriptValidationCode()
Grabs the compiled JS-validation-code for the element from its validator, if present and returns the code as a string.
FormElement::printMessages()
Returns a string of all aggregated error messages of the element.
FormElement::printName()
Compiles the html-name-string of the element.
FormElement::printNameArray()
Comiles the html-name-string of the element, if the element is part of a group of values.
FormElement::printTabIndex()
Calculates current ongoing tabindex of the form, refreshes it and returns the proper value for the element.
FormElement::printTitle()
Compiles the html-title-string of the element.
FormElement::printWrapperClasses()
Compiles a string of all classes for the tag-wrapper for the element's html-code.
FormElement::setCssClasses()
Sets the html-class-attribute for the element.
FormElement::setDisabled()
Set the element disabled.
FormElement::setId()
Sets the html-id for this element.
FormElement::setJavascriptEventHandler()
Sets a javascript-handler for the element.
FormElement::setLabel()
Inserts a label for the element.
FormElement::setMasterElement()
Sets the owning element for an element.
FormElement::setMasterForm()
Sets the owning form for an element and by doing so inserts the element into the logical structure of the form.
FormElement::setTitle()
Sets the html-title for this element.
FormElement::setUsable()
Set the element usables or disabled based on an expression.
FormElement::setValidator()
Sets a validator for a value-bearing element.
FormElement::validate()
Starts validation for the element and all subelements according to the rules laid out in the element's validator.

Class Details

[line 24]
Wraps a select.

This class implements a select in all its variations, be it as single-select, mulit-select, with or without optgroups. You name it. It's simply a very percise object-build of a select box.




Tags:

author:  Sebastian Schlapkohl
version:  1.0


[ Top ]


Class Variables

$multiple =

[line 33]



Tags:

access:  protected

Type:   mixed


[ Top ]

$optGroups =

[line 29]



Tags:

access:  protected

Type:   mixed


[ Top ]

$optionCssClasses =

[line 27]



Tags:

access:  protected

Type:   mixed


[ Top ]

$options =

[line 26]



Tags:

access:  protected

Type:   mixed


[ Top ]

$optionTitles =

[line 28]



Tags:

access:  protected

Type:   mixed


[ Top ]

$selected =

[line 30]



Tags:

access:  protected

Type:   mixed


[ Top ]

$size =

[line 32]



Tags:

access:  protected

Type:   mixed


[ Top ]

$subDisabled =

[line 31]



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


static method get [line 65]

static Select get( String $name, [String $id = ''])

Factory method for Select, returns new instance.

Factories are used to make instant chaining possible.




Tags:

return:  new Select-instance
access:  public


Overridden in child classes as:

SelectList::get()
Factory method for SelectList, returns new instance.

Parameters:

String   $name   html-name for the element
String   $id   html-id for the element

[ Top ]

constructor __construct [line 42]

Select __construct( String $name, [String $id = ''])

Hidden constructor.

Get new instances with "get()" instead.




Tags:

access:  protected


Overrides FormElement::__construct() (General abstract, hidden formelement constructor.)

Parameters:

String   $name   html-name for the element
String   $id   html-id for the element

[ Top ]

method doRender [line 375]

String doRender( )

Compiles and returns the html-fragment for the element.



Tags:

return:  html-fragment for the element
access:  public


Overridden in child classes as:

SelectList::doRender()
Compiles and returns the html-fragment for the element.

Overrides FormElement::doRender() (Returns the compiled html-code for the element.)

[ Top ]

method getValue [line 227]

String/Array[String] getValue( )

Returns the current value of the element.

A Select returns either a single string, if it's a single-select or and array of string when being multi-selectable. Both are compiled from the currently selected options of course.




Tags:

return:  the value(s) of (all) currently selected option(s)
access:  public


Overrides FormElement::getValue() (Returns the value of the element if there is any.)

[ Top ]

method isDisabledOption [line 269]

void isDisabledOption( $index, $value)



Tags:

access:  protected


Parameters:

   $index  
   $value  

[ Top ]

method isSelectedOption [line 259]

void isSelectedOption( $index, $value)



Tags:

access:  protected


Parameters:

   $index  
   $value  

[ Top ]

method refill [line 290]

Select refill( [Array[String]|null $refiller = array()], [Boolean $condition = true])

Tries to refill the selected options from existing data.

This data can eiter be one of the method-arrays dependent on the method the surrounding form uses or a supplied array of name-value-pairs.




Tags:

return:  method owner
access:  public


Parameters:

Array[String]|null   $refiller   data to use as the refill source
Boolean   $condition   expression which defines if the refill will take place or not, to make it conditional so to speak

[ Top ]

method setDisabled [line 203]

FormElement setDisabled( OPTIONAL 0)

Set the element disabled, or set single options disabled.



Tags:

return:  method owner
access:  public


Overrides FormElement::setDisabled() (Set the element disabled.)

Parameters:

OPTIONAL   0   * $subDisabled single/multiple indices/values to disable, multiple values must be enclosed in an array

[ Top ]

method setMultiple [line 189]

Select setMultiple( )

Set the select to being a multi-select.



Tags:

return:  method owner
access:  public


[ Top ]

method setOptionCssClasses [line 113]

Select setOptionCssClasses( $classes)

Sets css-classes to set for the options.

This could be used for an even-odd-pattern for example. One specialty of this functionality: the classes cycle. If you have 4 options for example and you define two classes of "even" and "odd", there will be two subsequent groups of "even" and "odd".

The order of the classes is that in which the options have been defined.




Tags:

return:  method owner
access:  public


Parameters:

Array[String]   $classes   css-classes to apply to the options

[ Top ]

method setOptions [line 84]

Select setOptions( $options)

Sets all available options of the select.

The options have to be given in the form of an associative array, where keys are the option-values and values are the texts for each option. array('val1' => 'nice option', 'val2' => 'not so nice option', ...)




Tags:

return:  method owner
access:  public


Parameters:

Array[String]   $options   the options for the select

[ Top ]

method setOptionTitles [line 130]

Select setOptionTitles( $titles, Array[String] $classes)

Sets html-title to set for the options.

The same speciality here as with the classes: they cycle, if not enough were defined for all options. If you have 4 options and you define two classes, there will be two subsequent groups of of both titles.

The order of the titles is that in which the options have been defined.




Tags:

return:  method owner
access:  public


Parameters:

Array[String]   $classes   html-titles to apply to the options
Array   $titles  

[ Top ]

method setSelected [line 143]

Select setSelected( * $selected)

Sets selected single/multiple options by index/value.



Tags:

return:  method owner
access:  public


Parameters:

*   $selected   single index/value or array of indices/values to select

[ Top ]

method setSingle [line 177]

Select setSingle( )

Set the select to being a single-select.



Tags:

return:  method owner
access:  public


[ Top ]

method setSize [line 165]

Select setSize( uint $size)

Sets the amount of rows the select should have, especially needed for multi-selects.



Tags:

return:  method owner
access:  public


Parameters:

uint   $size   amount of rows

[ Top ]

method validate [line 318]

Boolean validate( )

Starts the validation-process for the element.

Calculates the validity-status, based on the currently selected options, by applying the rules of a present validator. If there is none, the element is always valid.




Tags:

return:  element is currently valid yes/no
access:  public


Overrides FormElement::validate() (Starts validation for the element and all subelements according to the rules laid out in the element's validator.)

[ Top ]


Documentation generated on Fri, 18 Jul 2014 16:32:00 +0200 by phpDocumentor 1.4.3