AnewtFormControlCheckbox class

Form control for a single checkbox.

Class Overview

Form control for a single checkbox.

This control renders a HTML input element. Checkboxes have two labels, label and secondary-label, both of which may be set (both optional). Form renderers should render the label value just like labels for other controls are rendered. The secondary-label (if set) will be shown right next to the checkbox itself.

If you want multiple consecutive AnewtFormControlCheckbox controls to have the user check zero or more items, consider using AnewtFormControlChoice with the multiple property enabled instead.

Note that for yes/no-like questions you may also use AnewtFormControlChoice with just two options (and make sure it renders as two radio buttons; this is the default if you have just 2 options).

Public Methods

__construct($name)

Create a new AnewtFormControlCheckbox instance.

Parameters

$name

The name of this control.

fill($values)

Fill the form control from the given values.

This only sets the value for controls for which the can-be-filled property is enabled.

The return value of this function indicates whether the control was successfully filled with a value. For some control types such as checkboxes this always succeeds since both presence and absence of the value from $values are meaningful. For other controls such as text inputs this is only true if the value was actually present in the $values parameters.

Parameters

$values

An associative array from which the form control should be filled.

Return value

true if filling was succesfull, false otherwise.

See also

build_widget()

Render the minimal HTML needed for this control to work.

Form control implementations should implement this method, e.g. for a checkbox a simple input HTML element should be returned.

Return value

XHTML element with the minimal HTML markup needed for this control to function properly.

Inheritance

Base Classes

Inherited members