Formagic_Item_Checkbox

package Formagic\Item
author Florian Sonnenburg
since 0.2.0 First time introduced
inherited_from \Formagic_Item_Abstract

 Methods

Constructor

__construct(string $name, array $arguments = array()
Inherited

Parameters

$name

string

Name of item

$arguments

array

Additional arguments

Exceptions

\Formagic_Exception

Returns the HTML string representation of the form item.

__toString() : string
Inherited

Returns

stringThe HTML string representation.

Adds an HTML attribute to the attributes stack.

addAttribute(string $name, string $value) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$name

string

Attribute name

$value

string

Attribute value

Returns

\Formagic_Item_AbstractThis object.

Adds filter object to Formagic item

addFilter(mixed $filter, array $args = null) : \Formagic_Item_Abstract
Inherited

Formagic items can have multiple filters which will be applied in the order they are passed to the object.

First parameter $filter can either be a string or an object of a class that extends Formagic_Filter_Interface. A string value is assumed to be the type of filter to be added.

This method throws an exception if no valid role object can be identified.

Implements a fluent interface pattern.

Parameters

$filter

mixed

Filter type string or Formagic_Filter_Interface object.

$args

array

Optional array of arguments. Will be passed to the filter constructor as array.

Exceptions

\Formagic_Exception

Returns

\Formagic_Item_AbstractFluent interface

Adds rule object to Formagic item

addRule(mixed $rule, array $args = array()) : \Formagic_Item_Abstract
Inherited

Formagic items can have multiple rules which will be applied in the order they are passed to the object.

First parameter $rule can either be a string or an instance of a class that extends Formagic_Rule_Abstract. A string value is assumed to be the type of rule to be added.

Implements a fluent interface pattern.

Parameters

$rule

mixed

Rule type string or Formagic_Rule_Abstract object.

$args

array

Optional array of arguments. Will be passed to the rule constructor as array.

Exceptions

\Formagic_Exception If no valid role object can be identified.

Returns

\Formagic_Item_AbstractThis object.

Returns value of an attribute for this item.

getAttribute(string $name) : string
Inherited
see
see

Parameters

$name

string

Name of the attribute value to fetch

Returns

stringAttribute value

Returns attribute string for HTML tag.

getAttributeStr() : string
Inherited

Takes the attributes array and transforms it into a string that can be directly inserted into a HTML tag. The string will be built with a trailing space character.

Two default attributes are added to the attributes string: "name" and "id". If you want to skip these, add them to your attributes on item generation or via \setAttributes() or \addAttribute() with NULL as value.

$item->setAttributes(array('class' => 'myclass', 'onclick' => 'alert('Formagic');')); $string = $item->getAttributeStr(); echo ''; // output will be: //

see
see

Returns

stringThe attributes string.

Returns the attributes array for this item.

getAttributes() : array
Inherited
see
see

Returns

arrayThe attributes array.

Returns HTML representation of checkbox item.

getHtml() : string

Should be overwritten by subclasses.

see
inherited_from \Formagic_Item_Abstract::getHtml()

Returns

string

HTML template for renderers that use HTML-Code.

getHtml() : string
Inherited

Should be overwritten by subclasses.

Returns

stringThe HTML string representation of this item.

Returns label for this item.

getLabel() : string
Inherited

Returns

stringThe label string.

Returns the item name.

getName() : string
Inherited

Returns

stringThe item name

Returns item type.

getType() : string
Inherited

Returns

string

Returns current unfiltered value for this item.

getUnfilteredValue() : mixed
Inherited

Returns

mixedThe unfiltered item value

Returns the current filtered value for this item.

getValue() : string
Inherited

Returns

stringThe filtered item value

Returns array of violated rules.

getViolatedRules() : array
Inherited

If no rules were violated or if no validation has been performed yet, an empty array will be returned.

Returns

arrayThe violated rules.

Checks if a specific filter is defined for a Formagic item.

hasFilter(string $filterName) : boolean
Inherited

Parameters

$filterName

string

Filter name

Returns

booleanCheck value

Tells if a rule exists for this item.

hasRule(string $ruleName) : boolean
Inherited

The $ruleName parameter has to be a string with the name of rule that is looked for. If you want to know for example if the item has the mandatory rule added, $ruleName would have to be 'mandatory'.

The search string is case insensitive.

<?php // add a rule to the item object $mandatory = new Formagic_Rule_Mandatory(); $item->addRule($mandatory);

// look for the rule $ruleExists = $item->hasRule('mandatory'); // would return TRUE $ruleExists = $item->hasRule('Mandatory'); // would return TRUE $ruleExists = $item->hasRule('Formagic_Rule_Mandatory'); // would return FALSE ?>

Parameters

$ruleName

string

Rule name, eg. 'Mandatory'

Returns

boolean

Returns disabled status of item

isDisabled() : boolean
Inherited

Returns

booleanThe disabled status.

Returns hidden status of item

isHidden() : boolean
Inherited

Returns

booleanThe hidden status.

Returns ignore status of item

isIgnored() : boolean
Inherited

Returns

booleanThe ignored status.

Prints item infos.

printInfo() : string
Inherited

Returns

stringThe item information string

Sets additional attributes for this item.

setAttributes(array $attArray) : \Formagic_Item_Abstract
Inherited

Mainly used for additional HTML attributes other than "name", "id" or "value", such as "style", "class", javascript-handlers etc. Attributes are added corresponding to key->value-pairs in $attArray.

setAttributes() will overwrite any previously added item attributes.

Implements a fluent interface pattern.

see

Parameters

$attArray

array

The new

Returns

\Formagic_Item_AbstractThis object.

Sets disabled flag for item and removes it from form

setDisabled(boolean $flag) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$flag

boolean

Defined item's disabled status.

Returns

\Formagic_Item_AbstractFluent interface

Sets isFixed flag.

setFixed(boolean $flag) : \Formagic_Item_Abstract
Inherited

If set to true, all following calls to setValue() will be ignored.

Implements a fluent interface pattern.

Parameters

$flag

boolean

IsFixed flag value.

Returns

\Formagic_Item_AbstractThis object.

Sets hidden flag for item.

setHidden(boolean $flag) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$flag

boolean

Hidden status flag.

Returns

\Formagic_Item_AbstractThis object.

Defines if the item will be ignored in form submit.

setIgnore(boolean $flag) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$flag

boolean

Ignored status flag.

Returns

\Formagic_Item_AbstractThis object.

Sets readonly flag

setReadonly(boolean $flag) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$flag

boolean

Readonly status flag.

Returns

\Formagic_Item_AbstractThis object.

Defines which attributes are always to be added to this input element.

setRequiredAttributes(array $requiredAttributes) : \Formagic_Item_Abstract
Inherited

Default required attributes are "id" and "name".

Parameters

$requiredAttributes

array

Numeric array of required attributes.

Returns

\Formagic_Item_AbstractFluent interface.

Sets the item value to $value.

setValue(mixed $value) : \Formagic_Item_Abstract
Inherited

Implements a fluent interface pattern.

Parameters

$value

mixed

The new item value.

Returns

\Formagic_Item_AbstractThis object.

Performs rule checks

validate() : boolean
Inherited

Iterates through all defined rules of Formagic item. Returns true if all rules apply or false otherwise.

Returns

booleanThe validation result.

Assembles attribute string in HTML-conform style

_buildAttributeStr(array $attributes) : string
Inherited

Parameters

$attributes

array

array of attributes

Returns

stringAttributes string

Filters a value

_filterValue(\Formagic_Filter_Interface $filter, mixed $subject) : mixed
Inherited

Parameters

$filter

\Formagic_Filter_Interface

Filter object

$subject

mixed

Scalar or array

Exceptions

\Formagic_Exception if subject is not supported

Returns

mixedFiltered scalar or array

Allow subclass initialization.

_init(array $additionalArgs) : void
Inherited

Parameters

$additionalArgs

array

Array of arguments that are not processed by superclass.

Perform validation on item value.

_validateItemValue(\Formagic_Rule_Abstract $rule, string|array|null $subject) : boolean
Inherited

Parameters

$rule

\Formagic_Rule_Abstract

Validation rule object

$subject

stringarraynull

Validation subject

Exceptions

\Formagic_Exception if $subject does not have any supported type

Returns

booleanValidation result

Takes a string and returns a valid DOM ID.

_makeDomId(string $str) : string
Inherited

Parameters

$str

string

String to convert to a DOM ID

Returns

stringValid DOM ID

 Properties

 

Additional attributes for item HTML tag

$_attributes : array

Default

array()
 

Array of input filters for this item

$_filters : array

Default

array()
 

Determines if item is removed from Formagic form.

$_isDisabled : boolean

Default

false
 

Determines if value can be changed.

$_isFixed : boolean

Default

false
 

Determines if item will be displayed

$_isHidden : boolean

Default

false
 

Determines if item content should be interpreted after submit.

$_isIgnored : boolean

Default

false
 

Determines if item content can be edited.

$_isReadonly : boolean

Default

false
 

Form item label

$_label : boolean

Default

''
 

Form item name

$_name : string

Default

 

Array of required attributes for this item

$_requiredAttributes : array

Default

array('id', 'name')
 

Array of rule object that are applied for this item

$_rules : array

Default

array()
 

Item value

$_value : mixed

Default

 

Item type

$type : string

Default

'checkbox'
inherited_from \Formagic_Item_Abstract::type
 

Keyword to determine what kind of item is represented by the current item class

$type : string

Default

'undefined'
 

Filtered item value cache

$_filteredValue : mixed

Default

 

Violated rule after validation

$_violatedRules : \Formagic_Rule_Abstract

Default

array()