interface FormInterface implements ArrayAccess, Traversable, Countable
A form group bundling multiple forms in a hierarchical structure.
FormInterface | setParent(FormInterface $parent = null) Sets the parent form. | |
FormInterface|null | getParent() Returns the parent form. | |
FormInterface | add(FormInterface|string|int $child, string|null $type = null, array $options = array()) Adds or replaces a child to the form. | |
FormInterface | get(string $name) Returns the child with the given name. | |
bool | has(string $name) Returns whether a child with the given name exists. | |
$this | remove(string $name) Removes a child from the form. | |
FormInterface[] | all() Returns all children in this group. | |
FormErrorIterator | getErrors(bool $deep = false, bool $flatten = true) Returns the errors of this form. | |
$this | 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. | |
bool | isSubmitted() Returns whether the form is submitted. | |
string | getName() Returns the name by which the form is identified in forms. | |
PropertyPathInterface|null | getPropertyPath() Returns the property path that the form is mapped to. | |
$this | addError(FormError $error) Adds an error to this form. | |
bool | isValid() Returns whether the form and all children are valid. | |
bool | isRequired() Returns whether the form is required to be filled out. | |
bool | isDisabled() Returns whether this form is disabled. | |
bool | isEmpty() Returns whether the form is empty. | |
bool | isSynchronized() Returns whether the data in the different formats is synchronized. | |
TransformationFailedException|null | getTransformationFailure() Returns the data transformation failure, if any. | |
$this | initialize() Initializes the form tree. | |
$this | handleRequest(mixed $request = null) Inspects the given request and calls {@link submit()} if the form was submitted. | |
$this | submit(mixed $submittedData, bool $clearMissing = true) Submits data to the form, transforms and validates it. | |
FormInterface | getRoot() Returns the root of the form tree. | |
bool | isRoot() Returns whether the field is the root of the form tree. | |
FormView | createView(FormView $parent = null) Creates a view. |
Sets the parent form.
FormInterface | $parent |
FormInterface |
AlreadySubmittedException | if the form has already been submitted |
LogicException | when trying to set a parent for a form with an empty name |
Returns the parent form.
FormInterface|null | The parent form or null if there is none |
Adds or replaces a child to the form.
FormInterface|string|int | $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 |
FormInterface |
AlreadySubmittedException | if the form has already been submitted |
LogicException | when trying to add a child to a non-compound form |
UnexpectedTypeException | if $child or $type has an unexpected type |
Returns the child with the given name.
string | $name | The name of the child |
FormInterface |
OutOfBoundsException | if the named child does not exist |
Returns whether a child with the given name exists.
string | $name | The name of the child |
bool |
Removes a child from the form.
string | $name | The name of the child to remove |
$this |
AlreadySubmittedException | if the form has already been submitted |
Returns all children in this group.
FormInterface[] |
Returns the errors of this form.
bool | $deep | Whether to include errors of child forms as well |
bool | $flatten | Whether to flatten the list of errors in case $deep is set to true |
FormErrorIterator | An iterator over the {@link FormError} instances that where added to this form |
Updates the form with default data.
mixed | $modelData | The data formatted as expected for the underlying object |
$this |
AlreadySubmittedException | if the form has already been submitted |
LogicException | 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}. |
Returns the data in the format needed for the underlying object.
mixed |
Returns the normalized data of the field.
mixed | When the field is not submitted, the default data is returned. When the field is submitted, the normalized submitted data is returned if the field is valid, null otherwise. |
Returns the data transformed by the value transformer.
mixed |
Returns the extra data.
array | The submitted data which do not belong to a child |
Returns the form's configuration.
FormConfigInterface | The configuration |
Returns whether the form is submitted.
bool | true if the form is submitted, false otherwise |
Returns the name by which the form is identified in forms.
string | The name of the form |
Returns the property path that the form is mapped to.
PropertyPathInterface|null | The property path |
Adds an error to this form.
FormError | $error |
$this |
Returns whether the form and all children are valid.
bool |
LogicException | if the form is not submitted |
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.
bool |
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.
bool |
Returns whether the form is empty.
bool |
Returns whether the data in the different formats is synchronized.
If the data is not synchronized, you can get the transformation failure by calling {@link getTransformationFailure()}.
bool |
Returns the data transformation failure, if any.
TransformationFailedException|null | The transformation failure |
Initializes the form tree.
Should be called on the root form after constructing the tree.
$this |
Inspects the given request and calls {@link submit()} if the form was submitted.
Internally, the request is forwarded to the configured {@link RequestHandlerInterface} instance, which determines whether to submit the form or not.
mixed | $request | The request to handle |
$this |
Submits data to the form, transforms and validates it.
mixed | $submittedData | The submitted data |
bool | $clearMissing | Whether to set fields to NULL when they are missing in the submitted data |
$this |
AlreadySubmittedException | if the form has already been submitted |
Returns the root of the form tree.
FormInterface | The root of the tree |
Returns whether the field is the root of the form tree.
bool |
Creates a view.
FormView | $parent |
FormView | The view |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Form/FormInterface.html