Documentation

Form extends Child
in package
implements FormInterface, ArrayAccess, Countable, IteratorAggregate Uses FormTrait

Form class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

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

$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

addColumn()

Method to add form column

public addColumn(mixed $fieldsets[, string|null $class = null ]) : Form
Parameters
$fieldsets : mixed
$class : string|null = null
Return values
Form

addFieldFromConfig()

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
Form

addFields()

Method to add form fields

public addFields(array<string|int, mixed> $fields) : Form
Parameters
$fields : array<string|int, mixed>
Return values
Form

addFieldsetsFromConfig()

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
Form

addFieldsFromConfig()

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
Form

addNodeValue()

Add to the child node value

public addNodeValue(string $value) : Child
Parameters
$value : string
Return values
Child

clearTokens()

Method to clear any security tokens

public clearTokens() : Form
Return values
Form

count()

Method to get the count of elements in the form

public count() : int
Return values
int

create()

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
Child

createFieldset()

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
Fieldset

createFromConfig()

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
Form

createFromFieldsetConfig()

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
Form

filter()

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|null

getAllErrors()

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|null

getAttributes()

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|null

getChildNodes()

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>|null

getCurrent()

Method to get current fieldset index

public getCurrent() : int
Return values
int

getErrors()

Get form element errors for a field.

public getErrors(string $name) : array<string|int, mixed>
Parameters
$name : string
Return values
array<string|int, mixed>

getFields()

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|null

getFieldsets()

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
string

getIterator()

Method to iterate over the form elements

public getIterator() : ArrayIterator
Return values
ArrayIterator

getLegend()

Method to get the legend of the current fieldset

public getLegend() : string|null
Return values
string|null

getMethod()

Method to get method

public getMethod() : string|null
Return values
string|null

getNodeContent()

Return the child node content, including tags, etc

public getNodeContent([bool $ignoreWhiteSpace = false ]) : string
Parameters
$ignoreWhiteSpace : bool = false
Return values
string

getNodeName()

Return the child node name

public getNodeName() : string|null
Return values
string|null

getNodeValue()

Return the child node value

public getNodeValue() : string|null
Return values
string|null

getTextContent()

Return the child node content, including tags, etc

public getTextContent([bool $ignoreWhiteSpace = false ]) : string
Parameters
$ignoreWhiteSpace : bool = false
Return values
string

hasAttribute()

Determine if the child object has an attribute

public hasAttribute(string $name) : bool
Parameters
$name : string
Return values
bool

hasAttributes()

Determine if the child object has attributes

public hasAttributes() : bool
Return values
bool

hasChildNodes()

Get whether or not the child object has children (alias)

public hasChildNodes() : bool
Return values
bool

hasChildren()

Get whether or not the child object has children

public hasChildren() : bool
Return values
bool

hasColumn()

Method to determine if form has a column

public hasColumn(string $class) : bool
Parameters
$class : string
Return values
bool

hasField()

Has a field element object

public hasField(string $name) : bool
Parameters
$name : string
Return values
bool

hasFields()

Has fields

public hasFields() : bool
Return values
bool

hasFieldsets()

Method to determine if the form has fieldsets

public hasFieldsets() : bool
Return values
bool

isCData()

Determine if the child node value is CDATA

public isCData() : bool
Return values
bool

isChildrenFirst()

Determine if child nodes render first, before the node value

public isChildrenFirst() : bool
Return values
bool

isValid()

Determine whether or not the form object is valid

public isValid() : bool
Return values
bool

offsetExists()

ArrayAccess offsetExists

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

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
throws
Exception
Return values
Child

parseString()

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
Form

prepareForView()

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
Child

removeAttribute()

Remove an attribute from the child element object

public removeAttribute(string $name) : Child
Parameters
$name : string
Return values
Child

removeChild()

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
Form

removeField()

Method to remove a form field

public removeField(string $field) : Form
Parameters
$field : string
Return values
Form

removeFieldset()

Method to remove fieldset

public removeFieldset(int $i) : Form
Parameters
$i : int
Return values
Form

render()

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|null

reset()

Method to reset and clear any form field values

public reset() : Form
Return values
Form

setAction()

Method to set action

public setAction(string $action) : Form
Parameters
$action : string
Return values
Form

setAsCData()

Set the child node value as CDATA

public setAsCData([bool $cData = true ]) : Child
Parameters
$cData : bool = true
Return values
Child

setAttribute()

Method to set an attribute

public setAttribute(string $name[, mixed $value = null ]) : Form
Parameters
$name : string
$value : mixed = null
Return values
Form

setAttributes()

Method to set attributes

public setAttributes(array<string|int, mixed> $attributes) : Form
Parameters
$attributes : array<string|int, mixed>
Return values
Form

setChildrenFirst()

Set whether child nodes render first, before the node value

public setChildrenFirst([bool $first = true ]) : Child
Parameters
$first : bool = true
Return values
Child

setCurrent()

Method to get current fieldset index

public setCurrent(int $i) : Form
Parameters
$i : int
Return values
Form

setFieldValue()

Method to set a field element value

public setFieldValue(string $name, mixed $value) : Form
Parameters
$name : string
$value : mixed
Return values
Form

setFieldValues()

Method to set field element values

public setFieldValues(array<string|int, mixed> $values) : Form
Parameters
$values : array<string|int, mixed>
Return values
Form

setLegend()

Method to set the legend of the current fieldset

public setLegend(string $legend) : Form
Parameters
$legend : string
Return values
Form

setMethod()

Method to set method

public setMethod(string $method) : Form
Parameters
$method : string
Return values
Form

setNodeName()

Set the child node name

public setNodeName(string $name) : Child
Parameters
$name : string
Return values
Child

setNodeValue()

Set the child node value

public setNodeValue(string $value) : Child
Parameters
$value : string
Return values
Child

toArray()

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> = []
Return values
array<string|int, mixed>

        
On this page

Search results