Creates a group of checkbox elements.

package FormItBuilder

 Methods

FormItBuilder_elementCheckboxGroup

__construct(string $id, string $label, array $values) 

Creates a group of checkboxes that allow rules such as required, minimum length (minimum number of items that must be checked) and maximum length (maximum number of items that can be checked). The list of checkbox values are specified in an array along with their default ticked state.

$a_checkArray=array(
array('title'=>'Cheese','checked'=>false),
array('title'=>'Grapes','checked'=>true),
array('title'=>'Salad','checked'=>false),
array('title'=>'Bread','checked'=>true)
);
$o_fe_checkgroup        = new FormItBuilder_elementCheckboxGroup('favFoods','Favorite Foods',$a_checkArray);
//Ensure at least 2 checkboxes are selected
$a_formRules[] = new FormRule(FormRuleType::minimumLength,$o_fe_checkgroup,2);
//Ensure no more than 3 checkboxes are selected
$a_formRules[] = new FormRule(FormRuleType::maximumLength,$o_fe_checkgroup,3);

Parameters

$id

string

Id of the element

$label

string

Label of the select element

$values

array

Array of title/value arrays in order of display.

getDescription()

getDescription() : string
Inherited

Returns the form elements description.

inherited_from \FormItBuilder_element::getDescription()

Returns

string

getId()

getId() : string
Inherited

Returns the form elements ID.

inherited_from \FormItBuilder_element::getId()

Returns

string

getLabel()

getLabel() : string
Inherited

Returns the form elements label.

inherited_from \FormItBuilder_element::getLabel()

Returns

string

getName()

getName() : string
Inherited

Returns the form elements name.

inherited_from \FormItBuilder_element::getName()

Returns

string

isRequired($value) / isRequired()

isRequired(boolean $value) : boolean
Inherited

Sets wether the element is required or not.

This setting is generally toggled automatically based on FormRule settings applied in the form.

If no value passed the method will return the current required status.

inherited_from \FormItBuilder_element::isRequired()

Parameters

$value

boolean

If true the field must be filled out.

Returns

boolean

outputHTML()

outputHTML() : string

Outputs the HTML for the element.

Returns

string

setDescription($value)

setDescription(string $value) 
Inherited

Allows a sub label (or more descriptive label) to be set within the element label. Could be shown on hover or displayed with main label.

inherited_from \FormItBuilder_element::setDescription()

Parameters

$value

string

setId($value)

setId(string $value) 
Inherited

Sets the form elements ID.

inherited_from \FormItBuilder_element::setId()

Parameters

$value

string

setLabel($value)

setLabel(string $value) 
Inherited

Sets the form elements label.

inherited_from \FormItBuilder_element::setLabel()

Parameters

$value

string

setMaxLength($value)

setMaxLength(int $value) 

Sets the maximum number of checkboxes that can be selected before the checkbox group will be valid (e.g. please select up to three options...).

Parameters

$value

int

setMinLength($value)

setMinLength(int $value) 

Sets the minimum number of checkboxes that must be selected before the checkbox group will be valid (e.g. please select at least two options...).

Parameters

$value

int

setName($value)

setName(string $value) 
Inherited

Sets the form elements name.

inherited_from \FormItBuilder_element::setName()

Parameters

$value

string

showInEmail($value) / showInEmail()

showInEmail(boolean $value) : boolean
Inherited

Sets wether the element is shown in the email or not.

In some cases fields may be wanted in the form, but not in the email (an example would be fields like a "Confirm Password" field).

If no value passed the method will return the current status.

inherited_from \FormItBuilder_element::showInEmail()

Parameters

$value

boolean

If true (which is in most cases default) the element will be shown in the email.

Returns

boolean

showIndividualLabels($value) / showIndividualLabels()

showIndividualLabels(boolean $value) : boolean

By default (true) each checkbox will have its own label. Users may wish to have checkboxes in some kind of table with custom surrounding HTML. In this case labels can be hidden. If no value passed the method will return the current label display status.

Parameters

$value

boolean

Returns

boolean

showLabel($value) / showLabel()

showLabel(boolean $value) : boolean
Inherited

Sets wether the label should be displayed for this element or not. If no value passed the method will return the current status.

inherited_from \FormItBuilder_element::showLabel()

Parameters

$value

boolean

If true (which is in most cases default) a label will be shown next to the form element and in the email.

Returns

boolean