Moodle  2.2.1
http://www.collinsharper.com
HTML_QuickForm_advcheckbox Class Reference
Inheritance diagram for HTML_QuickForm_advcheckbox:
Collaboration diagram for HTML_QuickForm_advcheckbox:

Public Member Functions

 HTML_QuickForm_advcheckbox ($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null)
 getPrivateName ($elementName)
 getOnclickJs ($elementName)
 setValues ($values)
 setValue ($value)
 getValue ()
 toHtml ()
 getFrozenHtml ()
 onQuickFormEvent ($event, $arg, &$caller)
 exportValue (&$submitValues, $assoc)

Data Fields

 $_values = null
 $_currentValue = null

Detailed Description

HTML class for an advanced checkbox type field

Basically this fixes a problem that HTML has had where checkboxes can only pass a single value (the value of the checkbox when checked). A value for when the checkbox is not checked cannot be passed, and furthermore the checkbox variable doesn't even exist if the checkbox was submitted unchecked.

It works by prepending a hidden field with the same name and another "unchecked" value to the checbox. If the checkbox is checked, PHP overwrites the value of the hidden field with its value.

Author:
Jason Rust <jrust@php.net>
Since:
2.0 public

Definition at line 43 of file advcheckbox.php.


Member Function Documentation

exportValue ( &$  submitValues,
assoc 
)

This element has a value even if it is not checked, thus we override checkbox's behaviour here

Reimplemented from HTML_QuickForm_checkbox.

Definition at line 265 of file advcheckbox.php.

Unlike checkbox, this has to append a hidden input in both checked and non-checked states

Reimplemented from HTML_QuickForm_checkbox.

Reimplemented in MoodleQuickForm_advcheckbox.

Definition at line 216 of file advcheckbox.php.

getOnclickJs ( elementName)

Create the javascript for the onclick event which will set the value of the hidden field

Parameters:
string$elementNameThe element name

public

Returns:
string
Deprecated:
Deprecated since 3.2.6, this element no longer uses any javascript

Definition at line 118 of file advcheckbox.php.

getPrivateName ( elementName)

Gets the private name for the element

Parameters:
string$elementNameThe element name to make private

public

Returns:
string
Deprecated:
Deprecated since 3.2.6, both generated elements have the same name

Definition at line 99 of file advcheckbox.php.

getValue ( )

Returns the element's value

public

Returns:
mixed

Reimplemented from HTML_QuickForm_checkbox.

Definition at line 176 of file advcheckbox.php.

HTML_QuickForm_advcheckbox ( elementName = null,
elementLabel = null,
text = null,
attributes = null,
values = null 
)

Class constructor

Parameters:
string$elementName(optional)Input field name attribute
string$elementLabel(optional)Input field label
string$text(optional)Text to put after the checkbox
mixed$attributes(optional)Either a typical HTML attribute string or an associative array
mixed$values(optional)Values to pass if checked or not checked
Since:
1.0 public
Returns:
void

Definition at line 80 of file advcheckbox.php.

Here is the call graph for this function:

Here is the caller graph for this function:

onQuickFormEvent ( event,
arg,
&$  caller 
)

Called by HTML_QuickForm whenever form event is made on this element

Parameters:
string$eventName of event
mixed$argevent arguments
object$callercalling object
Since:
1.0 public
Returns:
void

Reimplemented from HTML_QuickForm_checkbox.

Definition at line 235 of file advcheckbox.php.

setValue ( value)

Sets the element's value

Parameters:
mixedElement's value public

Reimplemented from HTML_QuickForm_checkbox.

Definition at line 161 of file advcheckbox.php.

setValues ( values)

Sets the values used by the hidden element

Parameters:
mixed$valuesThe values, either a string or an array

public

Returns:
void

Definition at line 136 of file advcheckbox.php.

Here is the caller graph for this function:

toHtml ( )

Returns the checkbox element in HTML and the additional hidden element in HTML

public

Returns:
string

Reimplemented from HTML_QuickForm_checkbox.

Reimplemented in MoodleQuickForm_advcheckbox.

Definition at line 195 of file advcheckbox.php.


Field Documentation

$_currentValue = null

Definition at line 61 of file advcheckbox.php.

$_values = null

Definition at line 53 of file advcheckbox.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations