FormBuilderInterface
extends
Traversable, Countable, FormConfigBuilderInterface
in
Tags
Table of Contents
Methods
- add() : static
- Adds a new field to this group. A field must have a unique name within the group. Otherwise the existing field is overwritten.
- addEventListener() : $this
- Adds an event listener to an event on this form.
- addEventSubscriber() : $this
- Adds an event subscriber for events on this form.
- addModelTransformer() : $this
- Prepends / appends a transformer to the normalization transformer chain.
- addViewTransformer() : $this
- Appends / prepends a transformer to the view transformer chain.
- all() : array<string, self>
- Returns the children.
- create() : self
- Creates a form builder.
- get() : self
- Returns a child by name.
- getAction() : string
- Returns the target URL of the form.
- getAttribute() : mixed
- Returns the value of the given attribute.
- getAttributes() : array<string|int, mixed>
- Returns additional attributes of the form.
- getAutoInitialize() : bool
- Returns whether the form should be initialized upon creation.
- getByReference() : bool
- Returns whether the form's data should be modified by reference.
- getCompound() : bool
- Returns whether the form is compound.
- getData() : mixed
- Returns the initial data of the form.
- getDataClass() : string|null
- Returns the class of the view data or null if the data is scalar or an array.
- getDataLocked() : bool
- Returns whether the form's data is locked.
- getDataMapper() : DataMapperInterface|null
- Returns the data mapper of the compound form or null for a simple form.
- getDisabled() : bool
- Returns whether the form is disabled.
- getEmptyData() : mixed
- Used when the view data is empty on submission.
- getErrorBubbling() : bool
- Returns whether errors attached to the form will bubble to its parent.
- getEventDispatcher() : EventDispatcherInterface
- Returns the event dispatcher used to dispatch form events.
- getForm() : FormInterface
- Creates the form.
- getFormConfig() : FormConfigInterface
- Builds and returns the form configuration.
- getFormFactory() : FormFactoryInterface
- Returns the form factory used for creating new forms.
- getInheritData() : bool
- Returns whether the form should read and write the data of its parent.
- getIsEmptyCallback() : callable|null
- Returns a callable that takes the model data as argument and that returns if it is empty or not.
- getMapped() : bool
- Returns whether the form should be mapped to an element of its parent's data.
- getMethod() : string
- Returns the HTTP method used by the form.
- getModelTransformers() : array<string|int, DataTransformerInterface>
- Returns the model transformers of the form.
- getName() : string
- Returns the name of the form used as HTTP parameter.
- getOption() : mixed
- Returns the value of a specific option.
- getOptions() : array<string, mixed>
- Returns all options passed during the construction of the form.
- getPropertyPath() : PropertyPathInterface|null
- Returns the property path that the form should be mapped to.
- getRequestHandler() : RequestHandlerInterface
- Returns the request handler used by the form.
- getRequired() : bool
- Returns whether the form is required.
- getType() : ResolvedFormTypeInterface
- Returns the resolved form type used to construct the form.
- getViewTransformers() : array<string|int, DataTransformerInterface>
- Returns the view transformers of the form.
- has() : bool
- Returns whether a field with the given name exists.
- hasAttribute() : bool
- Returns whether the attribute with the given name exists.
- hasOption() : bool
- Returns whether a specific option exists.
- remove() : static
- Removes the field with the given name.
- resetModelTransformers() : $this
- Clears the normalization transformers.
- resetViewTransformers() : $this
- Clears the view transformers.
- setAction() : $this
- Sets the target URL of the form.
- setAttribute() : $this
- Sets the value for an attribute.
- setAttributes() : $this
- Sets the attributes.
- setAutoInitialize() : $this
- Sets whether the form should be initialized automatically.
- setByReference() : $this
- Sets whether the form's data should be modified by reference.
- setCompound() : $this
- Sets whether the form should be compound.
- setData() : $this
- Sets the initial data of the form.
- setDataLocked() : $this
- Locks the form's data to the data passed in the configuration.
- setDataMapper() : $this
- Sets the data mapper used by the form.
- setDisabled() : $this
- Sets whether the form is disabled.
- setEmptyData() : $this
- Sets the data used for the client data when no value is submitted.
- setErrorBubbling() : $this
- Sets whether errors bubble up to the parent.
- setFormFactory() : mixed
- Sets the form factory used for creating new forms.
- setInheritData() : $this
- Sets whether the form should read and write the data of its parent.
- setIsEmptyCallback() : $this
- Sets the callback that will be called to determine if the model data of the form is empty or not.
- setMapped() : $this
- Sets whether the form should be mapped to an element of its parent's data.
- setMethod() : $this
- Sets the HTTP method used by the form.
- setPropertyPath() : $this
- Sets the property path that the form should be mapped to.
- setRequestHandler() : $this
- Sets the request handler used by the form.
- setRequired() : $this
- Sets whether this field is required to be filled out when submitted.
- setType() : $this
- Sets the resolved type.
Methods
add()
Adds a new field to this group. A field must have a unique name within the group. Otherwise the existing field is overwritten.
public
add(string|FormBuilderInterface $child[, string $type = null ][, array<string, mixed> $options = [] ]) : static
If you add a nested group, this group should also be represented in the object hierarchy.
Parameters
- $child : string|FormBuilderInterface
- $type : string = null
- $options : array<string, mixed> = []
Return values
staticaddEventListener()
Adds an event listener to an event on this form.
public
addEventListener(string $eventName, callable $listener[, int $priority = 0 ]) : $this
Parameters
- $eventName : string
- $listener : callable
- $priority : int = 0
-
The priority of the listener. Listeners with a higher priority are called before listeners with a lower priority.
Return values
$thisaddEventSubscriber()
Adds an event subscriber for events on this form.
public
addEventSubscriber(EventSubscriberInterface $subscriber) : $this
Parameters
- $subscriber : EventSubscriberInterface
Return values
$thisaddModelTransformer()
Prepends / appends a transformer to the normalization transformer chain.
public
addModelTransformer(DataTransformerInterface $modelTransformer[, bool $forceAppend = false ]) : $this
The transform method of the transformer is used to convert data from the model to the normalized format. The reverseTransform method of the transformer is used to convert from the normalized to the model format.
Parameters
- $modelTransformer : DataTransformerInterface
- $forceAppend : bool = false
-
If set to true, append instead of prepending
Return values
$thisaddViewTransformer()
Appends / prepends a transformer to the view transformer chain.
public
addViewTransformer(DataTransformerInterface $viewTransformer[, bool $forcePrepend = false ]) : $this
The transform method of the transformer is used to convert data from the normalized to the view format. The reverseTransform method of the transformer is used to convert from the view to the normalized format.
Parameters
- $viewTransformer : DataTransformerInterface
- $forcePrepend : bool = false
-
If set to true, prepend instead of appending
Return values
$thisall()
Returns the children.
public
all() : array<string, self>
Return values
array<string, self>create()
Creates a form builder.
public
create(string $name[, string|null $type = null ][, array<string, mixed> $options = [] ]) : self
Parameters
- $name : string
-
The name of the form or the name of the property
- $type : string|null = null
-
The type of the form or null if name is a property
- $options : array<string, mixed> = []
Return values
selfget()
Returns a child by name.
public
get(string $name) : self
Parameters
- $name : string
Tags
Return values
selfgetAction()
Returns the target URL of the form.
public
getAction() : string
Return values
stringgetAttribute()
Returns the value of the given attribute.
public
getAttribute(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
getAttributes()
Returns additional attributes of the form.
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getAutoInitialize()
Returns whether the form should be initialized upon creation.
public
getAutoInitialize() : bool
Return values
boolgetByReference()
Returns whether the form's data should be modified by reference.
public
getByReference() : bool
Return values
boolgetCompound()
Returns whether the form is compound.
public
getCompound() : bool
This property is independent of whether the form actually has children. A form can be compound and have no children at all, like for example an empty collection form. The contrary is not possible, a form which is not compound cannot have any children.
Return values
boolgetData()
Returns the initial data of the form.
public
getData() : mixed
getDataClass()
Returns the class of the view data or null if the data is scalar or an array.
public
getDataClass() : string|null
Return values
string|nullgetDataLocked()
Returns whether the form's data is locked.
public
getDataLocked() : bool
A form with locked data is restricted to the data passed in this configuration. The data can only be modified then by submitting the form.
Return values
boolgetDataMapper()
Returns the data mapper of the compound form or null for a simple form.
public
getDataMapper() : DataMapperInterface|null
Return values
DataMapperInterface|nullgetDisabled()
Returns whether the form is disabled.
public
getDisabled() : bool
Return values
boolgetEmptyData()
Used when the view data is empty on submission.
public
getEmptyData() : mixed
When the form is compound it will also be used to map the children data.
The empty data must match the view format as it will passed to the first view transformer's "reverseTransform" method.
getErrorBubbling()
Returns whether errors attached to the form will bubble to its parent.
public
getErrorBubbling() : bool
Return values
boolgetEventDispatcher()
Returns the event dispatcher used to dispatch form events.
public
getEventDispatcher() : EventDispatcherInterface
Return values
EventDispatcherInterfacegetForm()
Creates the form.
public
getForm() : FormInterface
Return values
FormInterfacegetFormConfig()
Builds and returns the form configuration.
public
getFormConfig() : FormConfigInterface
Return values
FormConfigInterfacegetFormFactory()
Returns the form factory used for creating new forms.
public
getFormFactory() : FormFactoryInterface
Return values
FormFactoryInterfacegetInheritData()
Returns whether the form should read and write the data of its parent.
public
getInheritData() : bool
Return values
boolgetIsEmptyCallback()
Returns a callable that takes the model data as argument and that returns if it is empty or not.
public
getIsEmptyCallback() : callable|null
Return values
callable|nullgetMapped()
Returns whether the form should be mapped to an element of its parent's data.
public
getMapped() : bool
Return values
boolgetMethod()
Returns the HTTP method used by the form.
public
getMethod() : string
Return values
stringgetModelTransformers()
Returns the model transformers of the form.
public
getModelTransformers() : array<string|int, DataTransformerInterface>
Return values
array<string|int, DataTransformerInterface>getName()
Returns the name of the form used as HTTP parameter.
public
getName() : string
Return values
stringgetOption()
Returns the value of a specific option.
public
getOption(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
getOptions()
Returns all options passed during the construction of the form.
public
getOptions() : array<string, mixed>
Return values
array<string, mixed> —The passed options
getPropertyPath()
Returns the property path that the form should be mapped to.
public
getPropertyPath() : PropertyPathInterface|null
Return values
PropertyPathInterface|nullgetRequestHandler()
Returns the request handler used by the form.
public
getRequestHandler() : RequestHandlerInterface
Return values
RequestHandlerInterfacegetRequired()
Returns whether the form is required.
public
getRequired() : bool
Return values
boolgetType()
Returns the resolved form type used to construct the form.
public
getType() : ResolvedFormTypeInterface
Return values
ResolvedFormTypeInterfacegetViewTransformers()
Returns the view transformers of the form.
public
getViewTransformers() : array<string|int, DataTransformerInterface>
Return values
array<string|int, DataTransformerInterface>has()
Returns whether a field with the given name exists.
public
has(string $name) : bool
Parameters
- $name : string
Return values
boolhasAttribute()
Returns whether the attribute with the given name exists.
public
hasAttribute(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
Returns whether a specific option exists.
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
boolremove()
Removes the field with the given name.
public
remove(string $name) : static
Parameters
- $name : string
Return values
staticresetModelTransformers()
Clears the normalization transformers.
public
resetModelTransformers() : $this
Return values
$thisresetViewTransformers()
Clears the view transformers.
public
resetViewTransformers() : $this
Return values
$thissetAction()
Sets the target URL of the form.
public
setAction(string $action) : $this
Parameters
- $action : string
Return values
$thissetAttribute()
Sets the value for an attribute.
public
setAttribute(string $name, mixed $value) : $this
Parameters
- $name : string
- $value : mixed
-
The value of the attribute
Return values
$thissetAttributes()
Sets the attributes.
public
setAttributes(array<string|int, mixed> $attributes) : $this
Parameters
- $attributes : array<string|int, mixed>
Return values
$thissetAutoInitialize()
Sets whether the form should be initialized automatically.
public
setAutoInitialize(bool $initialize) : $this
Should be set to true only for root forms.
Parameters
- $initialize : bool
-
True to initialize the form automatically, false to suppress automatic initialization. In the second case, you need to call manually.
Return values
$thissetByReference()
Sets whether the form's data should be modified by reference.
public
setByReference(bool $byReference) : $this
Parameters
- $byReference : bool
Return values
$thissetCompound()
Sets whether the form should be compound.
public
setCompound(bool $compound) : $this
Parameters
- $compound : bool
Tags
Return values
$thissetData()
Sets the initial data of the form.
public
setData(mixed $data) : $this
Parameters
- $data : mixed
-
The data of the form in model format
Return values
$thissetDataLocked()
Locks the form's data to the data passed in the configuration.
public
setDataLocked(bool $locked) : $this
A form with locked data is restricted to the data passed in this configuration. The data can only be modified then by submitting the form or using PRE_SET_DATA event.
It means data passed to a factory method or mapped from the parent will be ignored.
Parameters
- $locked : bool
Return values
$thissetDataMapper()
Sets the data mapper used by the form.
public
setDataMapper([DataMapperInterface $dataMapper = null ]) : $this
Parameters
- $dataMapper : DataMapperInterface = null
Return values
$thissetDisabled()
Sets whether the form is disabled.
public
setDisabled(bool $disabled) : $this
Parameters
- $disabled : bool
Return values
$thissetEmptyData()
Sets the data used for the client data when no value is submitted.
public
setEmptyData(mixed $emptyData) : $this
Parameters
- $emptyData : mixed
-
The empty data
Return values
$thissetErrorBubbling()
Sets whether errors bubble up to the parent.
public
setErrorBubbling(bool $errorBubbling) : $this
Parameters
- $errorBubbling : bool
Return values
$thissetFormFactory()
Sets the form factory used for creating new forms.
public
setFormFactory(FormFactoryInterface $formFactory) : mixed
Parameters
- $formFactory : FormFactoryInterface
setInheritData()
Sets whether the form should read and write the data of its parent.
public
setInheritData(bool $inheritData) : $this
Parameters
- $inheritData : bool
Return values
$thissetIsEmptyCallback()
Sets the callback that will be called to determine if the model data of the form is empty or not.
public
setIsEmptyCallback(callable|null $isEmptyCallback) : $this
Parameters
- $isEmptyCallback : callable|null
Return values
$thissetMapped()
Sets whether the form should be mapped to an element of its parent's data.
public
setMapped(bool $mapped) : $this
Parameters
- $mapped : bool
Return values
$thissetMethod()
Sets the HTTP method used by the form.
public
setMethod(string $method) : $this
Parameters
- $method : string
Return values
$thissetPropertyPath()
Sets the property path that the form should be mapped to.
public
setPropertyPath(string|PropertyPathInterface|null $propertyPath) : $this
Parameters
- $propertyPath : string|PropertyPathInterface|null
-
The property path or null if the path should be set automatically based on the form's name
Return values
$thissetRequestHandler()
Sets the request handler used by the form.
public
setRequestHandler(RequestHandlerInterface $requestHandler) : $this
Parameters
- $requestHandler : RequestHandlerInterface
Return values
$thissetRequired()
Sets whether this field is required to be filled out when submitted.
public
setRequired(bool $required) : $this
Parameters
- $required : bool
Return values
$thissetType()
Sets the resolved type.
public
setType(ResolvedFormTypeInterface $type) : $this
Parameters
- $type : ResolvedFormTypeInterface