Form
extends Child
in package
implements
FormInterface, ArrayAccess, Countable, IteratorAggregate
Uses
FormTrait
Form class
Tags
Table of Contents
Interfaces
- FormInterface
- Form interface class
- ArrayAccess
- Countable
- IteratorAggregate
Properties
- $attributes : array<string|int, mixed>
- Child element attributes
- $cData : bool
- Child element node value CDATA flag
- $childNodes : array<string|int, mixed>
- Object child nodes
- $childrenFirst : bool
- Flag to render children before node value or not
- $columns : array<string|int, mixed>
- Form columns
- $current : int
- Current field fieldset
- $fieldsets : array<string|int, mixed>
- Field fieldsets
- $indent : string|null
- Indentation for formatting purposes
- $nodeName : string|null
- Child element node name
- $nodeValue : string|null
- Child element node value
- $output : string|null
- Child output
- $parent : AbstractNode|null
- Parent node
- $preserveWhiteSpace : bool
- Flag to preserve whitespace
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get method to return the value of fields[$name]
- __isset() : bool
- Return the isset value of fields[$name]
- __set() : void
- Set method to set the property to the value of fields[$name]
- __toString() : string
- Render and return the form object as a string
- __unset() : void
- Unset fields[$name]
- addChild() : AbstractNode
- Add a child to the object
- addChildren() : AbstractNode
- Add children to the object
- addColumn() : Form
- Method to add form column
- addField() : Form
- Method to add a form field
- addFieldFromConfig() : Form
- Method to add a form field from a config
- addFields() : Form
- Method to add form fields
- addFieldset() : Form
- Method to add fieldset
- addFieldsetsFromConfig() : Form
- Method to add form fieldsets from config
- addFieldsFromConfig() : Form
- Method to add form fields from config
- addNodeValue() : Child
- Add to the child node value
- clearTokens() : Form
- Method to clear any security tokens
- count() : int
- Method to get the count of elements in the form
- create() : Child
- Static factory method to create a child object
- createFieldset() : Fieldset
- Method to create a new fieldset object
- createFromConfig() : Form
- Method to create form object and fields from config
- createFromFieldsetConfig() : Form
- Method to create form object and fields from config
- filter() : mixed
- Filter values with the filters in the form object
- filterValue() : mixed
- Filter value with the filters in the form object
- getAction() : string|null
- Method to get action
- getAllErrors() : array<string|int, mixed>
- Get all form element errors
- getAttribute() : string|null
- Get the attribute of the child object
- getAttributes() : array<string|int, mixed>
- Get the attributes of the child object
- getChild() : Child|null
- Get the child nodes of the object
- getChildNodes() : array<string|int, mixed>
- Get the child nodes of the object (alias)
- getChildren() : array<string|int, mixed>
- Get the child nodes of the object
- getColumn() : array<string|int, mixed>|null
- Method to get form column
- getCurrent() : int
- Method to get current fieldset index
- getErrors() : array<string|int, mixed>
- Get form element errors for a field.
- getField() : AbstractElement|null
- Method to get a field element object
- getFields() : array<string|int, mixed>
- Method to get field element objects
- getFieldset() : Fieldset|null
- Method to get current fieldset
- getFieldsets() : array<string|int, mixed>
- Method to get all fieldsets
- getFieldValue() : mixed
- Method to get a field element value
- getIndent() : string
- Return the indent
- getIterator() : ArrayIterator
- Method to iterate over the form elements
- getLegend() : string|null
- Method to get the legend of the current fieldset
- getMethod() : string|null
- Method to get method
- getNodeContent() : string
- Return the child node content, including tags, etc
- getNodeName() : string|null
- Return the child node name
- getNodeValue() : string|null
- Return the child node value
- getParent() : AbstractNode|null
- Return the parent node
- getTextContent() : string
- Return the child node content, including tags, etc
- hasAttribute() : bool
- Determine if the child object has an attribute
- hasAttributes() : bool
- Determine if the child object has attributes
- hasChildNodes() : bool
- Get whether or not the child object has children (alias)
- hasChildren() : bool
- Get whether or not the child object has children
- hasColumn() : bool
- Method to determine if form has a column
- hasField() : bool
- Has a field element object
- hasFields() : bool
- Has fields
- hasFieldsets() : bool
- Method to determine if the form has fieldsets
- insertFieldAfter() : Form
- Method to insert a field after another one
- insertFieldBefore() : Form
- Method to insert a field before another one
- isCData() : bool
- Determine if the child node value is CDATA
- isChildrenFirst() : bool
- Determine if child nodes render first, before the node value
- isValid() : bool
- Determine whether or not the form object is valid
- offsetExists() : bool
- ArrayAccess offsetExists
- offsetGet() : mixed
- ArrayAccess offsetGet
- offsetSet() : void
- ArrayAccess offsetSet
- offsetUnset() : void
- ArrayAccess offsetUnset
- parseFile() : Child
- Static method to parse an XML/HTML string from a file
- parseString() : Child|array<string|int, mixed>
- Static method to parse an XML/HTML string
- prepare() : Form
- Prepare form object for rendering
- prepareForView() : array<string|int, mixed>
- Prepare form object for rendering with a view
- preserveWhiteSpace() : Child
- Set whether to preserve whitespace
- removeAttribute() : Child
- Remove an attribute from the child element object
- removeChild() : void
- Remove all child nodes from the object
- removeChildren() : void
- Remove all child nodes from the object
- removeColumn() : Form
- Method to remove form column
- removeField() : Form
- Method to remove a form field
- removeFieldset() : Form
- Method to remove fieldset
- render() : string|null
- Render the form object
- reset() : Form
- Method to reset and clear any form field values
- setAction() : Form
- Method to set action
- setAsCData() : Child
- Set the child node value as CDATA
- setAttribute() : Form
- Method to set an attribute
- setAttributes() : Form
- Method to set attributes
- setChildrenFirst() : Child
- Set whether child nodes render first, before the node value
- setCurrent() : Form
- Method to get current fieldset index
- setFieldValue() : Form
- Method to set a field element value
- setFieldValues() : Form
- Method to set field element values
- setIndent() : AbstractNode
- Set the indent
- setLegend() : Form
- Method to set the legend of the current fieldset
- setMethod() : Form
- Method to set method
- setNodeName() : Child
- Set the child node name
- setNodeValue() : Child
- Set the child node value
- setParent() : AbstractNode
- Set the parent node
- toArray() : array<string|int, mixed>
- Method to get the field values as an array
Properties
$attributes
Child element attributes
protected
array<string|int, mixed>
$attributes
= []
$cData
Child element node value CDATA flag
protected
bool
$cData
= false
$childNodes
Object child nodes
protected
array<string|int, mixed>
$childNodes
= []
$childrenFirst
Flag to render children before node value or not
protected
bool
$childrenFirst
= false
$columns
Form columns
protected
array<string|int, mixed>
$columns
= []
$current
Current field fieldset
protected
int
$current
= 0
$fieldsets
Field fieldsets
protected
array<string|int, mixed>
$fieldsets
= []
$indent
Indentation for formatting purposes
protected
string|null
$indent
= null
$nodeName
Child element node name
protected
string|null
$nodeName
= null
$nodeValue
Child element node value
protected
string|null
$nodeValue
= null
$output
Child output
protected
string|null
$output
= null
$parent
Parent node
protected
AbstractNode|null
$parent
= null
$preserveWhiteSpace
Flag to preserve whitespace
protected
bool
$preserveWhiteSpace
= true
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed>|null $fields = null ][, string|null $action = null ][, string $method = 'post' ]) : mixed
Instantiate the form object
Parameters
- $fields : array<string|int, mixed>|null = null
- $action : string|null = null
- $method : string = 'post'
__get()
Get method to return the value of fields[$name]
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Return the isset value of fields[$name]
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
Set method to set the property to the value of fields[$name]
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
__toString()
Render and return the form object as a string
public
__toString() : string
Return values
string__unset()
Unset fields[$name]
public
__unset(string $name) : void
Parameters
- $name : string
addChild()
Add a child to the object
public
addChild(Child $c) : AbstractNode
Parameters
- $c : Child
Tags
Return values
AbstractNodeaddChildren()
Add children to the object
public
addChildren(mixed $children) : AbstractNode
Parameters
- $children : mixed
Tags
Return values
AbstractNodeaddColumn()
Method to add form column
public
addColumn(mixed $fieldsets[, string|null $class = null ]) : Form
Parameters
- $fieldsets : mixed
- $class : string|null = null
Return values
FormaddField()
Method to add a form field
public
addField(AbstractElement $field[, string|null $container = null ]) : Form
Parameters
- $field : AbstractElement
- $container : string|null = null
Return values
FormaddFieldFromConfig()
Method to add a form field from a config
public
addFieldFromConfig(string $name, array<string|int, mixed> $field) : Form
Parameters
- $name : string
- $field : array<string|int, mixed>
Return values
FormaddFields()
Method to add form fields
public
addFields(array<string|int, mixed> $fields) : Form
Parameters
- $fields : array<string|int, mixed>
Return values
FormaddFieldset()
Method to add fieldset
public
addFieldset(Fieldset $fieldset) : Form
Parameters
- $fieldset : Fieldset
Return values
FormaddFieldsetsFromConfig()
Method to add form fieldsets from config
public
addFieldsetsFromConfig(array<string|int, mixed>|FormConfig $fieldsets[, string|null $container = null ]) : Form
Parameters
- $fieldsets : array<string|int, mixed>|FormConfig
- $container : string|null = null
Return values
FormaddFieldsFromConfig()
Method to add form fields from config
public
addFieldsFromConfig(array<string|int, mixed>|FormConfig $config[, string|null $container = null ]) : Form
Parameters
- $config : array<string|int, mixed>|FormConfig
- $container : string|null = null
Return values
FormaddNodeValue()
Add to the child node value
public
addNodeValue(string $value) : Child
Parameters
- $value : string
Return values
ChildclearTokens()
Method to clear any security tokens
public
clearTokens() : Form
Return values
Formcount()
Method to get the count of elements in the form
public
count() : int
Return values
intcreate()
Static factory method to create a child object
public
static create(string $name[, string|null $value = null ][, array<string|int, mixed> $options = [] ]) : Child
Parameters
- $name : string
- $value : string|null = null
- $options : array<string|int, mixed> = []
Return values
ChildcreateFieldset()
Method to create a new fieldset object
public
createFieldset([string|null $legend = null ][, string|null $container = null ]) : Fieldset
Parameters
- $legend : string|null = null
- $container : string|null = null
Return values
FieldsetcreateFromConfig()
Method to create form object and fields from config
public
static createFromConfig(array<string|int, mixed>|FormConfig $config[, string|null $container = null ][, string|null $action = null ][, string $method = 'post' ]) : Form
Parameters
- $config : array<string|int, mixed>|FormConfig
- $container : string|null = null
- $action : string|null = null
- $method : string = 'post'
Return values
FormcreateFromFieldsetConfig()
Method to create form object and fields from config
public
static createFromFieldsetConfig(array<string|int, mixed>|FormConfig $config[, string|null $container = null ][, string|null $action = null ][, string $method = 'post' ]) : Form
Parameters
- $config : array<string|int, mixed>|FormConfig
- $container : string|null = null
- $action : string|null = null
- $method : string = 'post'
Return values
Formfilter()
Filter values with the filters in the form object
public
filter([mixed $values = null ]) : mixed
Parameters
- $values : mixed = null
filterValue()
Filter value with the filters in the form object
public
filterValue(mixed $field) : mixed
Parameters
- $field : mixed
getAction()
Method to get action
public
getAction() : string|null
Return values
string|nullgetAllErrors()
Get all form element errors
public
getAllErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>getAttribute()
Get the attribute of the child object
public
getAttribute(string $name) : string|null
Parameters
- $name : string
Return values
string|nullgetAttributes()
Get the attributes of the child object
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getChild()
Get the child nodes of the object
public
getChild(int $i) : Child|null
Parameters
- $i : int
Return values
Child|nullgetChildNodes()
Get the child nodes of the object (alias)
public
getChildNodes() : array<string|int, mixed>
Return values
array<string|int, mixed>getChildren()
Get the child nodes of the object
public
getChildren() : array<string|int, mixed>
Return values
array<string|int, mixed>getColumn()
Method to get form column
public
getColumn(string $class) : array<string|int, mixed>|null
Parameters
- $class : string
Return values
array<string|int, mixed>|nullgetCurrent()
Method to get current fieldset index
public
getCurrent() : int
Return values
intgetErrors()
Get form element errors for a field.
public
getErrors(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed>getField()
Method to get a field element object
public
getField(string $name) : AbstractElement|null
Parameters
- $name : string
Return values
AbstractElement|nullgetFields()
Method to get field element objects
public
getFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getFieldset()
Method to get current fieldset
public
getFieldset() : Fieldset|null
Return values
Fieldset|nullgetFieldsets()
Method to get all fieldsets
public
getFieldsets() : array<string|int, mixed>
Return values
array<string|int, mixed>getFieldValue()
Method to get a field element value
public
getFieldValue(string $name) : mixed
Parameters
- $name : string
getIndent()
Return the indent
public
getIndent() : string
Return values
stringgetIterator()
Method to iterate over the form elements
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetLegend()
Method to get the legend of the current fieldset
public
getLegend() : string|null
Return values
string|nullgetMethod()
Method to get method
public
getMethod() : string|null
Return values
string|nullgetNodeContent()
Return the child node content, including tags, etc
public
getNodeContent([bool $ignoreWhiteSpace = false ]) : string
Parameters
- $ignoreWhiteSpace : bool = false
Return values
stringgetNodeName()
Return the child node name
public
getNodeName() : string|null
Return values
string|nullgetNodeValue()
Return the child node value
public
getNodeValue() : string|null
Return values
string|nullgetParent()
Return the parent node
public
getParent() : AbstractNode|null
Return values
AbstractNode|nullgetTextContent()
Return the child node content, including tags, etc
public
getTextContent([bool $ignoreWhiteSpace = false ]) : string
Parameters
- $ignoreWhiteSpace : bool = false
Return values
stringhasAttribute()
Determine if the child object has an attribute
public
hasAttribute(string $name) : bool
Parameters
- $name : string
Return values
boolhasAttributes()
Determine if the child object has attributes
public
hasAttributes() : bool
Return values
boolhasChildNodes()
Get whether or not the child object has children (alias)
public
hasChildNodes() : bool
Return values
boolhasChildren()
Get whether or not the child object has children
public
hasChildren() : bool
Return values
boolhasColumn()
Method to determine if form has a column
public
hasColumn(string $class) : bool
Parameters
- $class : string
Return values
boolhasField()
Has a field element object
public
hasField(string $name) : bool
Parameters
- $name : string
Return values
boolhasFields()
Has fields
public
hasFields() : bool
Return values
boolhasFieldsets()
Method to determine if the form has fieldsets
public
hasFieldsets() : bool
Return values
boolinsertFieldAfter()
Method to insert a field after another one
public
insertFieldAfter(string $name, AbstractElement $field) : Form
Parameters
- $name : string
- $field : AbstractElement
Return values
ForminsertFieldBefore()
Method to insert a field before another one
public
insertFieldBefore(string $name, AbstractElement $field) : Form
Parameters
- $name : string
- $field : AbstractElement
Return values
FormisCData()
Determine if the child node value is CDATA
public
isCData() : bool
Return values
boolisChildrenFirst()
Determine if child nodes render first, before the node value
public
isChildrenFirst() : bool
Return values
boolisValid()
Determine whether or not the form object is valid
public
isValid() : bool
Return values
booloffsetExists()
ArrayAccess offsetExists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
ArrayAccess offsetGet
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
ArrayAccess offsetSet
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
offsetUnset()
ArrayAccess offsetUnset
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
parseFile()
Static method to parse an XML/HTML string from a file
public
static parseFile(string $file) : Child
Parameters
- $file : string
Tags
Return values
ChildparseString()
Static method to parse an XML/HTML string
public
static parseString(string $string) : Child|array<string|int, mixed>
Parameters
- $string : string
Return values
Child|array<string|int, mixed>prepare()
Prepare form object for rendering
public
prepare() : Form
Return values
FormprepareForView()
Prepare form object for rendering with a view
public
prepareForView() : array<string|int, mixed>
Return values
array<string|int, mixed>preserveWhiteSpace()
Set whether to preserve whitespace
public
preserveWhiteSpace([bool $preserve = true ]) : Child
Parameters
- $preserve : bool = true
Return values
ChildremoveAttribute()
Remove an attribute from the child element object
public
removeAttribute(string $a) : Child
Parameters
- $a : string
Return values
ChildremoveChild()
Remove all child nodes from the object
public
removeChild(int $i) : void
Parameters
- $i : int
removeChildren()
Remove all child nodes from the object
public
removeChildren() : void
removeColumn()
Method to remove form column
public
removeColumn(string $class) : Form
Parameters
- $class : string
Return values
FormremoveField()
Method to remove a form field
public
removeField(string $field) : Form
Parameters
- $field : string
Return values
FormremoveFieldset()
Method to remove fieldset
public
removeFieldset(int $i) : Form
Parameters
- $i : int
Return values
Formrender()
Render the form object
public
render([int $depth = 0 ][, string|null $indent = null ][, bool $inner = false ]) : string|null
Parameters
- $depth : int = 0
- $indent : string|null = null
- $inner : bool = false
Return values
string|nullreset()
Method to reset and clear any form field values
public
reset() : Form
Return values
FormsetAction()
Method to set action
public
setAction(string $action) : Form
Parameters
- $action : string
Return values
FormsetAsCData()
Set the child node value as CDATA
public
setAsCData([bool $cData = true ]) : Child
Parameters
- $cData : bool = true
Return values
ChildsetAttribute()
Method to set an attribute
public
setAttribute(string $a, string $v) : Form
Parameters
- $a : string
- $v : string
Return values
FormsetAttributes()
Method to set attributes
public
setAttributes(array<string|int, mixed> $a) : Form
Parameters
- $a : array<string|int, mixed>
Return values
FormsetChildrenFirst()
Set whether child nodes render first, before the node value
public
setChildrenFirst([bool $first = true ]) : Child
Parameters
- $first : bool = true
Return values
ChildsetCurrent()
Method to get current fieldset index
public
setCurrent(int $i) : Form
Parameters
- $i : int
Return values
FormsetFieldValue()
Method to set a field element value
public
setFieldValue(string $name, mixed $value) : Form
Parameters
- $name : string
- $value : mixed
Return values
FormsetFieldValues()
Method to set field element values
public
setFieldValues(array<string|int, mixed> $values) : Form
Parameters
- $values : array<string|int, mixed>
Return values
FormsetIndent()
Set the indent
public
setIndent(string $indent) : AbstractNode
Parameters
- $indent : string
Return values
AbstractNodesetLegend()
Method to set the legend of the current fieldset
public
setLegend(string $legend) : Form
Parameters
- $legend : string
Return values
FormsetMethod()
Method to set method
public
setMethod(string $method) : Form
Parameters
- $method : string
Return values
FormsetNodeName()
Set the child node name
public
setNodeName(string $name) : Child
Parameters
- $name : string
Return values
ChildsetNodeValue()
Set the child node value
public
setNodeValue(string $value) : Child
Parameters
- $value : string
Return values
ChildsetParent()
Set the parent node
public
setParent(AbstractNode $parent) : AbstractNode
Parameters
- $parent : AbstractNode
Return values
AbstractNodetoArray()
Method to get the field values as an array
public
toArray([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed> = []