Interface

Symfony\Component\Form\FormInterface

interface FormInterface implements ArrayAccess, Traversable, Countable

A form group bundling multiple forms in a hierarchical structure.

Methods

FormInterface setParent(FormInterface $parent = null)

Sets the parent form.

FormInterface|null getParent()

Returns the parent form.

FormInterface add(FormInterface|string|integer $child, string|null $type = null, array $options = array())

Adds a child to the form.

FormInterface get(string $name)

Returns the child with the given name.

Boolean has(string $name)

Returns whether a child with the given name exists.

FormInterface remove(string $name)

Removes a child from the form.

FormInterface[] all()

Returns all children in this group.

FormError[] getErrors()

Returns all errors.

FormInterface setData(mixed $modelData)

Updates the form with default data.

mixed getData()

Returns the data in the format needed for the underlying object.

mixed getNormData()

Returns the normalized data of the field.

mixed getViewData()

Returns the data transformed by the value transformer.

array getExtraData()

Returns the extra data.

FormConfigInterface getConfig()

Returns the form's configuration.

Boolean isBound()

Returns whether the field is bound.

string getName()

Returns the name by which the form is identified in forms.

PropertyPathInterface getPropertyPath()

Returns the property path that the form is mapped to.

FormInterface addError(FormError $error)

Adds an error to this form.

Boolean isValid()

Returns whether the form and all children are valid.

Boolean isRequired()

Returns whether the form is required to be filled out.

Boolean isDisabled()

Returns whether this form is disabled.

Boolean isEmpty()

Returns whether the form is empty.

Boolean isSynchronized()

Returns whether the data in the different formats is synchronized.

FormInterface bind(null|string|array $submittedData)

Binds data to the form, transforms and validates it.

FormInterface getRoot()

Returns the root of the form tree.

Boolean isRoot()

Returns whether the field is the root of the form tree.

FormView createView(FormView $parent = null)

Creates a view.

Details

at line 32
public FormInterface setParent(FormInterface $parent = null)

Sets the parent form.

Parameters

FormInterface $parent The parent form or null if it's the root.

Return Value

FormInterface The form instance

Exceptions

AlreadyBoundException If the form has already been bound.
FormException When trying to set a parent for a form with an empty name.

at line 39
public FormInterface|null getParent()

Returns the parent form.

Return Value

FormInterface|null The parent form or null if there is none.

at line 54
public FormInterface add(FormInterface|string|integer $child, string|null $type = null, array $options = array())

Adds a child to the form.

Parameters

FormInterface|string|integer $child The FormInterface instance or the name of the child.
string|null $type The child's type, if a name was passed.
array $options The child's options, if a name was passed.

Return Value

FormInterface The form instance

Exceptions

AlreadyBoundException If the form has already been bound.
FormException When trying to add a child to a non-compound form.
UnexpectedTypeException If $child or $type has an unexpected type.

at line 65
public FormInterface get(string $name)

Returns the child with the given name.

Parameters

string $name The name of the child

Return Value

FormInterface The child form

Exceptions

OutOfBoundsException If the named child does not exist.

at line 74
public Boolean has(string $name)

Returns whether a child with the given name exists.

Parameters

string $name The name of the child

Return Value

Boolean

at line 85
public FormInterface remove(string $name)

Removes a child from the form.

Parameters

string $name The name of the child to remove

Return Value

FormInterface The form instance

Exceptions

AlreadyBoundException If the form has already been bound.

at line 92
public FormInterface[] all()

Returns all children in this group.

Return Value

FormInterface[] An array of FormInterface instances

at line 99
public FormError[] getErrors()

Returns all errors.

Return Value

FormError[] An array of FormError instances that occurred during binding

at line 113
public FormInterface setData(mixed $modelData)

Updates the form with default data.

Parameters

mixed $modelData The data formatted as expected for the underlying object

Return Value

FormInterface The form instance

Exceptions

AlreadyBoundException If the form has already been bound.
FormException If listeners try to call setData in a cycle. Or if the view data does not match the expected type according to {@link FormConfigInterface::getDataClass}.

at line 120
public mixed getData()

Returns the data in the format needed for the underlying object.

Return Value

mixed

at line 129
public mixed getNormData()

Returns the normalized data of the field.

Return Value

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.

at line 136
public mixed getViewData()

Returns the data transformed by the value transformer.

Return Value

mixed

at line 143
public array getExtraData()

Returns the extra data.

Return Value

array The bound data which do not belong to a child

at line 150
public FormConfigInterface getConfig()

Returns the form's configuration.

Return Value

FormConfigInterface The configuration.

at line 157
public Boolean isBound()

Returns whether the field is bound.

Return Value

Boolean true if the form is bound to input values, false otherwise

at line 164
public string getName()

Returns the name by which the form is identified in forms.

Return Value

string The name of the form.

at line 171
public PropertyPathInterface getPropertyPath()

Returns the property path that the form is mapped to.

Return Value

PropertyPathInterface The property path.

at line 180
public FormInterface addError(FormError $error)

Adds an error to this form.

Parameters

FormError $error

Return Value

FormInterface The form instance

at line 187
public Boolean isValid()

Returns whether the form and all children are valid.

Return Value

Boolean

at line 198
public Boolean isRequired()

Returns whether the form is required to be filled out.

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.

Return Value

Boolean

at line 211
public Boolean isDisabled()

Returns whether this form is disabled.

The content of a disabled form is displayed, but not allowed to be modified. The validation of modified disabled forms should fail.

Forms whose parents are disabled are considered disabled regardless of their own state.

Return Value

Boolean

at line 218
public Boolean isEmpty()

Returns whether the form is empty.

Return Value

Boolean

at line 225
public Boolean isSynchronized()

Returns whether the data in the different formats is synchronized.

Return Value

Boolean

at line 236
public FormInterface bind(null|string|array $submittedData)

Binds data to the form, transforms and validates it.

Parameters

null|string|array $submittedData The data

Return Value

FormInterface The form instance

Exceptions

AlreadyBoundException If the form has already been bound.

at line 243
public FormInterface getRoot()

Returns the root of the form tree.

Return Value

FormInterface The root of the tree

at line 250
public Boolean isRoot()

Returns whether the field is the root of the form tree.

Return Value

Boolean

at line 259
public FormView createView(FormView $parent = null)

Creates a view.

Parameters

FormView $parent The parent view

Return Value

FormView The view