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

Class: InputCheckbox

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

Class Overview

FormElement
   |
   --InputCheckbox

Wraps a group of checkboxes.


Author(s):

  • Sebastian Schlapkohl

Version:

  • 1.0

Methods


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 31]
Wraps a group of checkboxes.

HtmlForm doesn't deal with single checkboxes but always with groups of them. Checkboxes are meant to be a form of multi-select-widget. Of course you can use this for creating single checkboxes, but be aware that the whole thing will still handle as if n boxes where present.

If you want you implement a binary decision (yes/no), which checkboxes are often used for, I'd rather suggest the use of accordingly labeled radio-buttons, to make things easier and to use widgets in the way the were intended to.

Setting a title or css-classes for this element will not result in anything. Instead, set titles and classes for the options themselves, by using the appropriate methods.




Tags:

author:  Sebastian Schlapkohl
version:  1.0


[ Top ]


Class Methods


static method get [line 67]

static InputCheckbox get( String $name)

Factory method for InputCheckbox, returns new instance.

Factories are used to make instant chaining possible.




Tags:

return:  new InputCheckbox-instance
access:  public


Parameters:

String   $name   html-name for the element

[ Top ]

constructor __construct [line 47]

InputCheckbox __construct( String $name)

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

[ Top ]

method doRender [line 301]

String doRender( )

Compiles and returns the html-fragment for the element.



Tags:

return:  html-fragment for the element
access:  public


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

[ Top ]

method getValue [line 190]

Array[String] getValue( )

Returns the current value of the element.

An InputCheckbox always returns an array of strings, which is compiled from the selected options.




Tags:

return:  the values of all currently selected options
access:  public


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

[ Top ]

method refill [line 238]

InputCheckbox 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 167]

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 setOptionCssClasses [line 104]

InputCheckbox 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 86]

InputCheckbox setOptions( $options)

Sets all available options of the checkbox-group.

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




Tags:

return:  method owner
access:  public


Parameters:

Array[String]   $options   the options for the checkbox-group

[ Top ]

method setOptionTitles [line 121]

InputCheckbox 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 134]

InputCheckbox setSelected( * $selected)

Sets selected single/multiple options by index/value/text.



Tags:

return:  method owner
access:  public


Parameters:

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

[ Top ]

method setWidth [line 153]

InputCheckbox setWidth( uint $width)

Set the amount of columns for the checkbox-display.

The width defines how many checkbox-label-pairs will be put into one row.




Tags:

return:  method owner
access:  public


Parameters:

uint   $width   the amount of checkboxes next to each other in one row

[ Top ]

method validate [line 266]

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:31:58 +0200 by phpDocumentor 1.4.3