__construct()
__toString()
addAttribute()
addFilter()
addRule()
getAttribute()
getAttributeStr()
getAttributes()
getHtml()
getLabel()
getName()
getSession()
getUnfilteredValue()
getValue()
getViolatedRules()
hasFilter()
hasRule()
isDisabled()
isHidden()
isIgnored()
printInfo()
setAttributes()
setDisabled()
setFixed()
setHidden()
setIgnore()
setReadonly()
setRequiredAttributes()
setSession()
setValue()
validate()
_buildAttributeStr()
_filterValue()
_init()
_initToken()
_validateItemValue()
_makeDomId()
$_attributes
$_filters
$_isDisabled
$_isFixed
$_isHidden
$_isIgnored
$_isReadonly
$_label
$_name
$_requiredAttributes
$_rules
$_session
$_value
$_filteredValue
$_ruleAdded
$_violatedRules
Protects a form from XSRF attacks.
category | Formagic |
---|---|
package | Item |
author | Florian Sonnenburg |
copyright | Copyright (c) 2007-2009 Florian Sonnenburg |
version | $Id: XsrfProtection.php 167 2012-05-01 13:37:06Z meweasle $ |
__construct(string $name, array $arguments) : void
inherited_from | \Formagic_Item_Abstract::__construct() |
---|---|
inherited_from | \Formagic_Item_Hidden::__construct() |
string
Name of item
array
Additional arguments
\Formagic_Exception |
---|
__toString() : string
inherited_from | \Formagic_Item_Abstract::__toString() |
---|---|
inherited_from | \Formagic_Item_Hidden::__toString() |
string
The HTML string representation.addAttribute(string $name, string $value) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::addAttribute() |
---|---|
inherited_from | \Formagic_Item_Hidden::addAttribute() |
string
Attribute name
string
Attribute value
\Formagic_Item_Abstract
This object.addFilter(mixed $filter, array $args) : \Formagic_Item_Abstract
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.
inherited_from | \Formagic_Item_Abstract::addFilter() |
---|---|
inherited_from | \Formagic_Item_Hidden::addFilter() |
mixed
Filter type string or Formagic_Filter_Interface object.
array
Optional array of arguments. Will be passed to the filter constructor as array.
\Formagic_Exception |
---|
\Formagic_Item_Abstract
Fluent interfaceaddRule(mixed $rule, array $args) : \Formagic_Item_Abstract
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.
inherited_from | \Formagic_Item_Abstract::addRule() |
---|---|
inherited_from | \Formagic_Item_Hidden::addRule() |
mixed
Rule type string or Formagic_Rule_Abstract object.
array
Optional array of arguments. Will be passed to the rule constructor as array.
\Formagic_Exception |
If no valid role object can be identified. |
---|
\Formagic_Item_Abstract
This object.getAttribute(string $name) : string
see | \Formagic_Item_Abstract::setAttributes() |
---|---|
see | \Formagic_Item_Abstract::addAttribute() |
inherited_from | \Formagic_Item_Abstract::getAttribute() |
inherited_from | \Formagic_Item_Hidden::getAttribute() |
string
Name of the attribute value to fetch
string
Attribute valuegetAttributeStr() : string
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 | \Formagic_Item_Abstract::setAttributes() |
---|---|
see | \Formagic_Item_Abstract::addAttribute() |
inherited_from | \Formagic_Item_Abstract::getAttributeStr() |
inherited_from | \Formagic_Item_Hidden::getAttributeStr() |
string
The attributes string.getAttributes() : array
see | \Formagic_Item_Abstract::setAttributes() |
---|---|
see | \Formagic_Item_Abstract::addAttribute() |
inherited_from | \Formagic_Item_Abstract::getAttributes() |
inherited_from | \Formagic_Item_Hidden::getAttributes() |
array
The attributes array.getHtml() : string
Should be overwritten by subclasses.
string
Field HTMLgetLabel() : string
inherited_from | \Formagic_Item_Abstract::getLabel() |
---|---|
inherited_from | \Formagic_Item_Hidden::getLabel() |
string
The label string.getName() : string
inherited_from | \Formagic_Item_Abstract::getName() |
---|---|
inherited_from | \Formagic_Item_Hidden::getName() |
string
The item namegetSession() : \Formagic_Session_Interface
\Formagic_Session_Interface
Session objectgetUnfilteredValue() : mixed
inherited_from | \Formagic_Item_Abstract::getUnfilteredValue() |
---|---|
inherited_from | \Formagic_Item_Hidden::getUnfilteredValue() |
mixed
The unfiltered item valuegetValue() : mixed
inherited_from | \Formagic_Item_Abstract::getValue() |
---|---|
inherited_from | \Formagic_Item_Hidden::getValue() |
mixed
The filtered item valuegetViolatedRules() : array
If no rules were violated or if no validation has been performed yet, an empty array will be returned.
inherited_from | \Formagic_Item_Abstract::getViolatedRules() |
---|---|
inherited_from | \Formagic_Item_Hidden::getViolatedRules() |
array
The violated rules.hasFilter(string $filterName) : boolean
inherited_from | \Formagic_Item_Abstract::hasFilter() |
---|---|
inherited_from | \Formagic_Item_Hidden::hasFilter() |
string
Filter name
boolean
Check valuehasRule(string $ruleName) : boolean
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.
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
?>
inherited_from | \Formagic_Item_Abstract::hasRule() |
---|---|
inherited_from | \Formagic_Item_Hidden::hasRule() |
string
Rule name, eg. 'Mandatory'
boolean
isDisabled() : boolean
inherited_from | \Formagic_Item_Abstract::isDisabled() |
---|---|
inherited_from | \Formagic_Item_Hidden::isDisabled() |
boolean
The disabled status.isHidden() : boolean
inherited_from | \Formagic_Item_Abstract::isHidden() |
---|---|
inherited_from | \Formagic_Item_Hidden::isHidden() |
boolean
The hidden status.isIgnored() : boolean
inherited_from | \Formagic_Item_Abstract::isIgnored() |
---|---|
inherited_from | \Formagic_Item_Hidden::isIgnored() |
boolean
The ignored status.printInfo() : string
inherited_from | \Formagic_Item_Abstract::printInfo() |
---|---|
inherited_from | \Formagic_Item_Hidden::printInfo() |
string
The item information stringsetAttributes(array $attArray) : \Formagic_Item_Abstract
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 | \Formagic_Item_Abstract::addAttribute() |
---|---|
inherited_from | \Formagic_Item_Abstract::setAttributes() |
inherited_from | \Formagic_Item_Hidden::setAttributes() |
array
The new
\Formagic_Item_Abstract
This object.setDisabled(boolean $flag) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setDisabled() |
---|---|
inherited_from | \Formagic_Item_Hidden::setDisabled() |
boolean
Defined item's disabled status.
\Formagic_Item_Abstract
Fluent interfacesetFixed(boolean $flag) : \Formagic_Item_Abstract
If set to true, all following calls to setValue() will be ignored.
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setFixed() |
---|---|
inherited_from | \Formagic_Item_Hidden::setFixed() |
boolean
IsFixed flag value.
\Formagic_Item_Abstract
This object.setHidden(boolean $flag) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setHidden() |
---|---|
inherited_from | \Formagic_Item_Hidden::setHidden() |
boolean
Hidden status flag.
\Formagic_Item_Abstract
This object.setIgnore(boolean $flag) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setIgnore() |
---|---|
inherited_from | \Formagic_Item_Hidden::setIgnore() |
boolean
Ignored status flag.
\Formagic_Item_Abstract
This object.setReadonly(boolean $flag) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setReadonly() |
---|---|
inherited_from | \Formagic_Item_Hidden::setReadonly() |
boolean
Readonly status flag.
\Formagic_Item_Abstract
This object.setRequiredAttributes(array $requiredAttributes) : \Formagic_Item_Abstract
Default required attributes are "id" and "name".
inherited_from | \Formagic_Item_Abstract::setRequiredAttributes() |
---|---|
inherited_from | \Formagic_Item_Hidden::setRequiredAttributes() |
array
Numeric array of required attributes.
\Formagic_Item_Abstract
Fluent interface.setValue(mixed $value) : \Formagic_Item_Abstract
Implements a fluent interface pattern.
inherited_from | \Formagic_Item_Abstract::setValue() |
---|---|
inherited_from | \Formagic_Item_Hidden::setValue() |
mixed
The new item value.
\Formagic_Item_Abstract
This object.validate() : boolean
Iterates through all defined rules of Formagic item. Returns true if all rules apply or false otherwise.
boolean
_buildAttributeStr(array $attributes) : string
inherited_from | \Formagic_Item_Abstract::_buildAttributeStr() |
---|---|
inherited_from | \Formagic_Item_Hidden::_buildAttributeStr() |
array
array of attributes
string
Attributes string_filterValue(Formagic_Filter_Interface $filter, mixed $subject) : mixed
inherited_from | \Formagic_Item_Abstract::_filterValue() |
---|---|
inherited_from | \Formagic_Item_Hidden::_filterValue() |
mixed
Scalar or array
mixed
Filtered scalar or array_init(array $additionalArgs) : void
_initToken() : void
_validateItemValue(Formagic_Rule_Abstract $rule, string | array $subject) : boolean
inherited_from | \Formagic_Item_Abstract::_validateItemValue() |
---|---|
inherited_from | \Formagic_Item_Hidden::_validateItemValue() |
stringarray
Validation subject
boolean
Validation result_makeDomId(string $str) : string
inherited_from | \Formagic_Item_Abstract::_makeDomId() |
---|---|
inherited_from | \Formagic_Item_Hidden::_makeDomId() |
string
String to convert to a DOM ID
string
Valid DOM ID$_attributes : array
inherited_from | \Formagic_Item_Abstract::$$_attributes |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_attributes |
$_filters : array
inherited_from | \Formagic_Item_Abstract::$$_filters |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_filters |
$_isDisabled : boolean
inherited_from | \Formagic_Item_Abstract::$$_isDisabled |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_isDisabled |
$_isFixed : boolean
inherited_from | \Formagic_Item_Abstract::$$_isFixed |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_isFixed |
$_isHidden : boolean
inherited_from | \Formagic_Item_Abstract::$$_isHidden |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_isHidden |
$_isIgnored : boolean
inherited_from | \Formagic_Item_Abstract::$$_isIgnored |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_isIgnored |
$_isReadonly : boolean
inherited_from | \Formagic_Item_Abstract::$$_isReadonly |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_isReadonly |
$_label : boolean
inherited_from | \Formagic_Item_Abstract::$$_label |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_label |
$_name : string
inherited_from | \Formagic_Item_Abstract::$$_name |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_name |
$_requiredAttributes : array
inherited_from | \Formagic_Item_Abstract::$$_requiredAttributes |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_requiredAttributes |
$_rules : array
inherited_from | \Formagic_Item_Abstract::$$_rules |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_rules |
$_value : mixed
inherited_from | \Formagic_Item_Abstract::$$_value |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_value |
$_filteredValue : mixed
inherited_from | \Formagic_Item_Abstract::$$_filteredValue |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_filteredValue |
$_ruleAdded : boolean
$_violatedRules : \Form_Rule_Abstract
inherited_from | \Formagic_Item_Abstract::$$_violatedRules |
---|---|
inherited_from | \Formagic_Item_Hidden::$$_violatedRules |