PHP Class Symfony\Component\Form\Form

A form is composed of a validator schema and a widget form schema. Form also takes care of CSRF protection by default. A CSRF secret can be any random string. If set to false, it disables the CSRF protection, and if set to null, it forces the form to use the global CSRF secret. If the global CSRF secret is also null, then a random one is generated on the fly.
Author: Fabien Potencier ([email protected])
Author: Bernhard Schussek ([email protected])
Inheritance: extends Field, implements IteratorAggregate, implements Symfony\Component\Form\FormInterface
Datei anzeigen Open project: pmjones/php-framework-benchmarks Class Usage Examples

Public Methods

Method Description
__clone ( )
__construct ( $name, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher, array $types = [], array $clientTransformers = [], array $normTransformers = [], Symfony\Component\Form\DataMapperInterface $dataMapper = null, array $validators = [], $required = false, $readOnly = false, $errorBubbling = false, $emptyData = null, array $attributes = [] )
add ( Symfony\Component\Form\FormInterface $child ) : Form Adds a child to the form.
addError ( FormError $error ) : Form Adds an error to this form.
bind ( string | array $clientData ) : Form Binds data to the field, transforms and validates it.
bindRequest ( Request $request ) : Form Binds a request to the form.
count ( ) : integer Returns the number of form children (implements the \Countable interface).
createView ( Symfony\Component\Form\FormView $parent = null ) : Symfony\Component\Form\FormView Creates a view.
get ( string $name ) : Symfony\Component\Form\FormInterface Returns the child with the given name.
getAttribute ( string $name ) Returns the value of the attributes with the given name.
getChildren ( ) : array Returns all children in this group.
getClientData ( ) : string Returns the data transformed by the value transformer.
getClientTransformers ( ) : array Returns the DataTransformers.
getData ( ) : mixed Returns the data in the format needed for the underlying object.
getErrorBubbling ( ) : boolean Returns whether errors bubble up to the parent.
getErrors ( ) : array Returns all errors.
getExtraData ( ) : array Returns the extra data.
getIterator ( ) : ArrayIterator Returns the iterator for this group.
getName ( ) : string Returns the name by which the form is identified in forms.
getNormData ( ) : mixed Returns the normalized data of the field.
getNormTransformers ( ) : array Returns the DataTransformers.
getParent ( ) : Symfony\Component\Form\FormInterface Returns the parent field.
getRoot ( ) : Symfony\Component\Form\FormInterface Returns the root of the form tree.
getTypes ( ) : array Returns the types used by this form.
has ( string $name ) : boolean Returns whether a child with the given name exists.
hasAttribute ( string $name ) Returns whether the form has an attribute with the given name.
hasChildren ( ) : boolean Return whether the form has children.
hasErrors ( ) : boolean Returns whether or not there are errors.
hasParent ( ) : boolean Returns whether the form has a parent.
isBound ( ) : boolean Returns whether the field is bound.
isEmpty ( ) : boolean Returns whether the form is empty.
isReadOnly ( ) : boolean Returns whether this form is read only.
isRequired ( ) : boolean Returns whether the form is required to be filled out.
isRoot ( ) : boolean Returns whether the field is the root of the form tree.
isSynchronized ( ) : boolean Returns whether the data in the different formats is synchronized.
isValid ( ) : boolean Returns whether the field is valid.
offsetExists ( string $name ) : boolean Returns true if the child exists (implements the \ArrayAccess interface).
offsetGet ( string $name ) : Symfony\Component\Form\FormInterface Returns the form child associated with the name (implements the \ArrayAccess interface).
offsetSet ( string $name, Symfony\Component\Form\FormInterface $child ) Adds a child to the form (implements the \ArrayAccess interface).
offsetUnset ( string $name ) Removes the child with the given name from the form (implements the \ArrayAccess interface).
remove ( string $name ) : Form Removes a child from the form.
setData ( array $appData ) : Form Updates the field with default data.
setParent ( Symfony\Component\Form\FormInterface $parent = null ) : Form Sets the parent form.

Private Methods

Method Description
appToNorm ( mixed $value ) : string Normalizes the value if a normalization transformer is set.
clientToNorm ( string $value ) : mixed Reverse transforms a value if a value transformer is set.
normToApp ( string $value ) : mixed Reverse transforms a value if a normalization transformer is set.
normToClient ( mixed $value ) : string Transforms the value if a value transformer is set.

Method Details

__clone() public method

public __clone ( )

__construct() public method

public __construct ( $name, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher, array $types = [], array $clientTransformers = [], array $normTransformers = [], Symfony\Component\Form\DataMapperInterface $dataMapper = null, array $validators = [], $required = false, $readOnly = false, $errorBubbling = false, $emptyData = null, array $attributes = [] )
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface
$types array
$clientTransformers array
$normTransformers array
$dataMapper Symfony\Component\Form\DataMapperInterface
$validators array
$attributes array

add() public method

Adds a child to the form.
public add ( Symfony\Component\Form\FormInterface $child ) : Form
$child Symfony\Component\Form\FormInterface The FormInterface to add as a child
return Form the current form

addError() public method

Adds an error to this form.
public addError ( FormError $error ) : Form
$error FormError
return Form The current form

bind() public method

Binds data to the field, transforms and validates it.
public bind ( string | array $clientData ) : Form
$clientData string | array The data
return Form The current form

bindRequest() public method

If the request method is POST, PUT or GET, the data is bound to the form, transformed and written into the form data (an object or an array).
public bindRequest ( Request $request ) : Form
$request Symfony\Component\HttpFoundation\Request The request to bind to the form
return Form This form

count() public method

Returns the number of form children (implements the \Countable interface).
public count ( ) : integer
return integer The number of embedded form children

createView() public method

Creates a view.
public createView ( Symfony\Component\Form\FormView $parent = null ) : Symfony\Component\Form\FormView
$parent Symfony\Component\Form\FormView The parent view
return Symfony\Component\Form\FormView The view

get() public method

Returns the child with the given name.
public get ( string $name ) : Symfony\Component\Form\FormInterface
$name string
return Symfony\Component\Form\FormInterface

getAttribute() public method

Returns the value of the attributes with the given name.
public getAttribute ( string $name )
$name string The name of the attribute

getChildren() public method

Returns all children in this group.
public getChildren ( ) : array
return array

getClientData() public method

Returns the data transformed by the value transformer.
public getClientData ( ) : string
return string

getClientTransformers() public method

Returns the DataTransformers.
public getClientTransformers ( ) : array
return array An array of DataTransformerInterface

getData() public method

Returns the data in the format needed for the underlying object.
public getData ( ) : mixed
return mixed

getErrorBubbling() public method

Returns whether errors bubble up to the parent.
public getErrorBubbling ( ) : boolean
return boolean

getErrors() public method

Returns all errors.
public getErrors ( ) : array
return array An array of FormError instances that occurred during binding

getExtraData() public method

Returns the extra data.
public getExtraData ( ) : array
return array The bound data which do not belong to a child

getIterator() public method

Returns the iterator for this group.

getName() public method

Returns the name by which the form is identified in forms.
public getName ( ) : string
return string The name of the form.

getNormData() public method

Returns the normalized data of the field.
public getNormData ( ) : mixed
return mixed When the field is not bound, the default data is returned. When the field is bound, the normalized bound data is returned if the field is valid, null otherwise.

getNormTransformers() public method

Returns the DataTransformers.
public getNormTransformers ( ) : array
return array An array of DataTransformerInterface

getParent() public method

Returns the parent field.
public getParent ( ) : Symfony\Component\Form\FormInterface
return Symfony\Component\Form\FormInterface The parent field

getRoot() public method

Returns the root of the form tree.
public getRoot ( ) : Symfony\Component\Form\FormInterface
return Symfony\Component\Form\FormInterface The root of the tree

getTypes() public method

Returns the types used by this form.
public getTypes ( ) : array
return array An array of FormTypeInterface

has() public method

Returns whether a child with the given name exists.
public has ( string $name ) : boolean
$name string
return boolean

hasAttribute() public method

Returns whether the form has an attribute with the given name.
public hasAttribute ( string $name )
$name string The name of the attribute

hasChildren() public method

Return whether the form has children.
public hasChildren ( ) : boolean
return boolean

hasErrors() public method

Returns whether or not there are errors.
public hasErrors ( ) : boolean
return boolean true if form is bound and not valid

hasParent() public method

Returns whether the form has a parent.
public hasParent ( ) : boolean
return boolean

isBound() public method

Returns whether the field is bound.
public isBound ( ) : boolean
return boolean true if the form is bound to input values, false otherwise

isEmpty() public method

Returns whether the form is empty.
public isEmpty ( ) : boolean
return boolean

isReadOnly() public method

The content of a read-only form is displayed, but not allowed to be modified. The validation of modified read-only forms should fail. Fields whose parents are read-only are considered read-only regardless of their own state.
public isReadOnly ( ) : boolean
return boolean

isRequired() public method

If the form has a parent and the parent is not required, this method will always return false. Otherwise the value set with setRequired() is returned.
public isRequired ( ) : boolean
return boolean

isRoot() public method

Returns whether the field is the root of the form tree.
public isRoot ( ) : boolean
return boolean

isSynchronized() public method

Returns whether the data in the different formats is synchronized.
public isSynchronized ( ) : boolean
return boolean

isValid() public method

Returns whether the field is valid.
public isValid ( ) : boolean
return boolean

offsetExists() public method

Returns true if the child exists (implements the \ArrayAccess interface).
public offsetExists ( string $name ) : boolean
$name string The name of the child
return boolean true if the widget exists, false otherwise

offsetGet() public method

Returns the form child associated with the name (implements the \ArrayAccess interface).
public offsetGet ( string $name ) : Symfony\Component\Form\FormInterface
$name string The offset of the value to get
return Symfony\Component\Form\FormInterface A form instance

offsetSet() public method

Adds a child to the form (implements the \ArrayAccess interface).
public offsetSet ( string $name, Symfony\Component\Form\FormInterface $child )
$name string Ignored. The name of the child is used.
$child Symfony\Component\Form\FormInterface The child to be added

offsetUnset() public method

Removes the child with the given name from the form (implements the \ArrayAccess interface).
public offsetUnset ( string $name )
$name string The name of the child to be removed

remove() public method

Removes a child from the form.
public remove ( string $name ) : Form
$name string The name of the child to remove
return Form the current form

setData() public method

Updates the field with default data.
public setData ( array $appData ) : Form
$appData array The data formatted as expected for the underlying object
return Form The current form

setParent() public method

Sets the parent form.
public setParent ( Symfony\Component\Form\FormInterface $parent = null ) : Form
$parent Symfony\Component\Form\FormInterface The parent form
return Form The current form