Interface

Symfony\Component\Form\FormBuilderInterface

interface FormBuilderInterface implements Traversable, Countable, FormConfigBuilderInterface

Methods

EventDispatcherInterface getEventDispatcher()

Returns the event dispatcher used to dispatch form events.

from FormConfigInterface
string getName()

Returns the name of the form used as HTTP parameter.

from FormConfigInterface
null|PropertyPathInterface getPropertyPath()

Returns the property path that the form should be mapped to.

from FormConfigInterface
Boolean getMapped()

Returns whether the form should be mapped to an element of its parent's data.

from FormConfigInterface
Boolean getByReference()

Returns whether the form's data should be modified by reference.

from FormConfigInterface
Boolean getVirtual()

Returns whether the form should be virtual.

from FormConfigInterface
Boolean getCompound()

Returns whether the form is compound.

from FormConfigInterface
ResolvedFormTypeInterface getType()

Returns the form types used to construct the form.

from FormConfigInterface
array getViewTransformers()

Returns the view transformers of the form.

from FormConfigInterface
array getModelTransformers()

Returns the model transformers of the form.

from FormConfigInterface
DataMapperInterface getDataMapper()

Returns the data mapper of the form.

from FormConfigInterface
FormValidatorInterface getValidators()

Returns the validators of the form.

from FormConfigInterface
Boolean getRequired()

Returns whether the form is required.

from FormConfigInterface
Boolean getDisabled()

Returns whether the form is disabled.

from FormConfigInterface
Boolean getErrorBubbling()

Returns whether errors attached to the form will bubble to its parent.

from FormConfigInterface
mixed getEmptyData()

Returns the data that should be returned when the form is empty.

from FormConfigInterface
array getAttributes()

Returns additional attributes of the form.

from FormConfigInterface
Boolean hasAttribute(string $name)

Returns whether the attribute with the given name exists.

from FormConfigInterface
mixed getAttribute(string $name, mixed $default = null)

Returns the value of the given attribute.

from FormConfigInterface
mixed getData()

Returns the initial data of the form.

from FormConfigInterface
string getDataClass()

Returns the class of the form data or null if the data is scalar or an array.

from FormConfigInterface
Boolean getDataLocked()

Returns whether the form's data is locked.

from FormConfigInterface
array getOptions()

Returns all options passed during the construction of the form.

from FormConfigInterface
Boolean hasOption(string $name)

Returns whether a specific option exists.

from FormConfigInterface
mixed getOption(string $name, mixed $default = null)

Returns the value of a specific option.

from FormConfigInterface
FormConfigBuilderInterface addEventListener(string $eventName, callable $listener, integer $priority)

Adds an event listener to an event on this form.

from FormConfigBuilderInterface
FormConfigBuilderInterface addEventSubscriber(EventSubscriberInterface $subscriber)

Adds an event subscriber for events on this form.

from FormConfigBuilderInterface
FormConfigBuilderInterface addValidator(FormValidatorInterface $validator)

Adds a validator to the form.

from FormConfigBuilderInterface
FormConfigBuilderInterface addViewTransformer(DataTransformerInterface $viewTransformer, Boolean $forcePrepend = false)

Appends / prepends a transformer to the view transformer chain.

from FormConfigBuilderInterface
FormConfigBuilderInterface resetViewTransformers()

Clears the view transformers.

from FormConfigBuilderInterface
FormConfigBuilderInterface addModelTransformer(DataTransformerInterface $modelTransformer, Boolean $forceAppend = false)

Prepends / appends a transformer to the normalization transformer chain.

from FormConfigBuilderInterface
FormConfigBuilderInterface resetModelTransformers()

Clears the normalization transformers.

from FormConfigBuilderInterface
FormConfigBuilderInterface setAttribute(string $name, string $value)

Sets the value for an attribute.

from FormConfigBuilderInterface
FormConfigBuilderInterface setAttributes(array $attributes)

Sets the attributes.

from FormConfigBuilderInterface
FormConfigBuilderInterface setDataMapper(DataMapperInterface $dataMapper = null)

Sets the data mapper used by the form.

from FormConfigBuilderInterface
FormConfigBuilderInterface setDisabled(Boolean $disabled)

Set whether the form is disabled.

from FormConfigBuilderInterface
FormConfigBuilderInterface setEmptyData(mixed $emptyData)

Sets the data used for the client data when no value is bound.

from FormConfigBuilderInterface
FormConfigBuilderInterface setErrorBubbling(Boolean $errorBubbling)

Sets whether errors bubble up to the parent.

from FormConfigBuilderInterface
FormConfigBuilderInterface setRequired(Boolean $required)

Sets whether this field is required to be filled out when bound.

from FormConfigBuilderInterface
FormConfigBuilderInterface setPropertyPath(null|string|PropertyPathInterface $propertyPath)

Sets the property path that the form should be mapped to.

from FormConfigBuilderInterface
FormConfigBuilderInterface setMapped(Boolean $mapped)

Sets whether the form should be mapped to an element of its parent's data.

from FormConfigBuilderInterface
FormConfigBuilderInterface setByReference(Boolean $byReference)

Sets whether the form's data should be modified by reference.

from FormConfigBuilderInterface
FormConfigBuilderInterface setVirtual(Boolean $virtual)

Sets whether the form should be virtual.

from FormConfigBuilderInterface
FormConfigBuilderInterface setCompound(Boolean $compound)

Sets whether the form should be compound.

from FormConfigBuilderInterface
FormConfigBuilderInterface setType(ResolvedFormTypeInterface $type)

Set the types.

from FormConfigBuilderInterface
FormConfigBuilderInterface setData(array $data)

Sets the initial data of the form.

from FormConfigBuilderInterface
FormConfigBuilderInterface setDataLocked(Boolean $locked)

Locks the form's data to the data passed in the configuration.

from FormConfigBuilderInterface
FormConfigInterface getFormConfig()

Builds and returns the form configuration.

from FormConfigBuilderInterface
FormBuilderInterface add(string|FormBuilderInterface $child, string|FormTypeInterface $type = null, array $options = array())

Adds a new field to this group.

FormBuilderInterface create(string $name, string|FormTypeInterface $type = null, array $options = array())

Creates a form builder.

FormBuilderInterface get(string $name)

Returns a child by name.

FormBuilderInterface remove(string $name)

Removes the field with the given name.

Boolean has(string $name)

Returns whether a field with the given name exists.

array all()

Returns the children.

FormFactoryInterface getFormFactory()

Returns the associated form factory.

Form getForm()

Creates the form.

FormBuilderInterface setParent(FormBuilderInterface $parent = null)

Sets the parent builder.

FormBuilderInterface getParent()

Returns the parent builder.

Boolean hasParent()

Returns whether the builder has a parent.

Details

in FormConfigInterface at line 26
public EventDispatcherInterface getEventDispatcher()

Returns the event dispatcher used to dispatch form events.

Return Value

EventDispatcherInterface The dispatcher.

in FormConfigInterface at line 33
public string getName()

Returns the name of the form used as HTTP parameter.

Return Value

string The form name.

in FormConfigInterface at line 40
public null|PropertyPathInterface getPropertyPath()

Returns the property path that the form should be mapped to.

Return Value

null|PropertyPathInterface The property path.

in FormConfigInterface at line 48
public Boolean getMapped()

Returns whether the form should be mapped to an element of its parent's data.

Return Value

Boolean Whether the form is mapped.

in FormConfigInterface at line 55
public Boolean getByReference()

Returns whether the form's data should be modified by reference.

Return Value

Boolean Whether to modify the form's data by reference.

in FormConfigInterface at line 66
public Boolean getVirtual()

Returns whether the form should be virtual.

When mapping data to the children of a form, the data mapper should ignore virtual forms and map to the children of the virtual form instead.

Return Value

Boolean Whether the form is virtual.

in FormConfigInterface at line 77
public Boolean getCompound()

Returns whether the form is compound.

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.

Return Value

Boolean Whether the form is compound.

in FormConfigInterface at line 84
public ResolvedFormTypeInterface getType()

Returns the form types used to construct the form.

Return Value

ResolvedFormTypeInterface The form's type.

in FormConfigInterface at line 91
public array getViewTransformers()

Returns the view transformers of the form.

Return Value

array An array of {@link DataTransformerInterface} instances.

in FormConfigInterface at line 98
public array getModelTransformers()

Returns the model transformers of the form.

Return Value

array An array of {@link DataTransformerInterface} instances.

in FormConfigInterface at line 105
public DataMapperInterface getDataMapper()

Returns the data mapper of the form.

Return Value

DataMapperInterface The data mapper.

in FormConfigInterface at line 114
public FormValidatorInterface getValidators()

Returns the validators of the form.

Return Value

FormValidatorInterface The form validator.

in FormConfigInterface at line 121
public Boolean getRequired()

Returns whether the form is required.

Return Value

Boolean Whether the form is required.

in FormConfigInterface at line 128
public Boolean getDisabled()

Returns whether the form is disabled.

Return Value

Boolean Whether the form is disabled.

in FormConfigInterface at line 135
public Boolean getErrorBubbling()

Returns whether errors attached to the form will bubble to its parent.

Return Value

Boolean Whether errors will bubble up.

in FormConfigInterface at line 142
public mixed getEmptyData()

Returns the data that should be returned when the form is empty.

Return Value

mixed The data returned if the form is empty.

in FormConfigInterface at line 149
public array getAttributes()

Returns additional attributes of the form.

Return Value

array An array of key-value combinations.

in FormConfigInterface at line 158
public Boolean hasAttribute(string $name)

Returns whether the attribute with the given name exists.

Parameters

string $name The attribute name.

Return Value

Boolean Whether the attribute exists.

in FormConfigInterface at line 168
public mixed getAttribute(string $name, mixed $default = null)

Returns the value of the given attribute.

Parameters

string $name The attribute name.
mixed $default The value returned if the attribute does not exist.

Return Value

mixed The attribute value.

in FormConfigInterface at line 175
public mixed getData()

Returns the initial data of the form.

Return Value

mixed The initial form data.

in FormConfigInterface at line 182
public string getDataClass()

Returns the class of the form data or null if the data is scalar or an array.

Return Value

string The data class or null.

in FormConfigInterface at line 193
public Boolean getDataLocked()

Returns whether the form's data is locked.

A form with locked data is restricted to the data passed in this configuration. The data can only be modified then by binding the form.

Return Value

Boolean Whether the data is locked.

in FormConfigInterface at line 200
public array getOptions()

Returns all options passed during the construction of the form.

Return Value

array The passed options.

in FormConfigInterface at line 209
public Boolean hasOption(string $name)

Returns whether a specific option exists.

Parameters

string $name The option name,

Return Value

Boolean Whether the option exists.

in FormConfigInterface at line 219
public mixed getOption(string $name, mixed $default = null)

Returns the value of a specific option.

Parameters

string $name The option name.
mixed $default The value returned if the option does not exist.

Return Value

mixed The option value.

public FormConfigBuilderInterface addEventListener(string $eventName, callable $listener, integer $priority)

Adds an event listener to an event on this form.

Parameters

string $eventName The name of the event to listen to.
callable $listener The listener to execute.
integer $priority The priority of the listener. Listeners with a higher priority are called before listeners with a lower priority.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface addEventSubscriber(EventSubscriberInterface $subscriber)

Adds an event subscriber for events on this form.

Parameters

EventSubscriberInterface $subscriber The subscriber to attach.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface addValidator(FormValidatorInterface $validator)

Adds a validator to the form.

Parameters

FormValidatorInterface $validator The validator.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface addViewTransformer(DataTransformerInterface $viewTransformer, Boolean $forcePrepend = false)

Appends / prepends a transformer to the view transformer chain.

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

DataTransformerInterface $viewTransformer
Boolean $forcePrepend if set to true, prepend instead of appending

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface resetViewTransformers()

Clears the view transformers.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface addModelTransformer(DataTransformerInterface $modelTransformer, Boolean $forceAppend = false)

Prepends / appends a transformer to the normalization transformer chain.

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

DataTransformerInterface $modelTransformer
Boolean $forceAppend if set to true, append instead of prepending

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface resetModelTransformers()

Clears the normalization transformers.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setAttribute(string $name, string $value)

Sets the value for an attribute.

Parameters

string $name The name of the attribute
string $value The value of the attribute

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setAttributes(array $attributes)

Sets the attributes.

Parameters

array $attributes The attributes.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setDataMapper(DataMapperInterface $dataMapper = null)

Sets the data mapper used by the form.

Parameters

DataMapperInterface $dataMapper

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setDisabled(Boolean $disabled)

Set whether the form is disabled.

Parameters

Boolean $disabled Whether the form is disabled

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setEmptyData(mixed $emptyData)

Sets the data used for the client data when no value is bound.

Parameters

mixed $emptyData The empty data.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setErrorBubbling(Boolean $errorBubbling)

Sets whether errors bubble up to the parent.

Parameters

Boolean $errorBubbling

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setRequired(Boolean $required)

Sets whether this field is required to be filled out when bound.

Parameters

Boolean $required

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setPropertyPath(null|string|PropertyPathInterface $propertyPath)

Sets the property path that the form should be mapped to.

Parameters

null|string|PropertyPathInterface $propertyPath The property path or null if the path should be set automatically based on the form's name.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setMapped(Boolean $mapped)

Sets whether the form should be mapped to an element of its parent's data.

Parameters

Boolean $mapped Whether the form should be mapped.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setByReference(Boolean $byReference)

Sets whether the form's data should be modified by reference.

Parameters

Boolean $byReference Whether the data should be modified by reference.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setVirtual(Boolean $virtual)

Sets whether the form should be virtual.

Parameters

Boolean $virtual Whether the form should be virtual.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setCompound(Boolean $compound)

Sets whether the form should be compound.

Parameters

Boolean $compound Whether the form should be compound.

Return Value

FormConfigBuilderInterface The configuration object.

See also

FormConfigInterface::getCompound()

public FormConfigBuilderInterface setType(ResolvedFormTypeInterface $type)

Set the types.

Parameters

ResolvedFormTypeInterface $type The type of the form.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setData(array $data)

Sets the initial data of the form.

Parameters

array $data The data of the form in application format.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigBuilderInterface setDataLocked(Boolean $locked)

Locks the form's data to the data passed in the configuration.

A form with locked data is restricted to the data passed in this configuration. The data can only be modified then by binding the form.

Parameters

Boolean $locked Whether to lock the default data.

Return Value

FormConfigBuilderInterface The configuration object.

public FormConfigInterface getFormConfig()

Builds and returns the form configuration.

Return Value

FormConfigInterface

at line 32
public FormBuilderInterface add(string|FormBuilderInterface $child, string|FormTypeInterface $type = null, array $options = array())

Adds a new field to this group.

A field must have a unique name within the group. Otherwise the existing field is overwritten.

If you add a nested group, this group should also be represented in the object hierarchy.

Parameters

string|FormBuilderInterface $child
string|FormTypeInterface $type
array $options

Return Value

FormBuilderInterface The builder object.

at line 43
public FormBuilderInterface create(string $name, string|FormTypeInterface $type = null, array $options = array())

Creates a form builder.

Parameters

string $name The name of the form or the name of the property
string|FormTypeInterface $type The type of the form or null if name is a property
array $options The options

Return Value

FormBuilderInterface The created builder.

at line 54
public FormBuilderInterface get(string $name)

Returns a child by name.

Parameters

string $name The name of the child

Return Value

FormBuilderInterface The builder for the child

Exceptions

FormException if the given child does not exist

at line 62
public FormBuilderInterface remove(string $name)

Removes the field with the given name.

Parameters

string $name

Return Value

FormBuilderInterface The builder object.

at line 71
public Boolean has(string $name)

Returns whether a field with the given name exists.

Parameters

string $name

Return Value

Boolean

at line 78
public array all()

Returns the children.

Return Value

array

at line 85
public FormFactoryInterface getFormFactory()

Returns the associated form factory.

Return Value

FormFactoryInterface The factory

at line 92
public Form getForm()

Creates the form.

Return Value

Form The form

at line 101
public FormBuilderInterface setParent(FormBuilderInterface $parent = null)

Sets the parent builder.

Parameters

FormBuilderInterface $parent The parent builder

Return Value

FormBuilderInterface The builder object.

at line 108
public FormBuilderInterface getParent()

Returns the parent builder.

Return Value

FormBuilderInterface The parent builder

at line 115
public Boolean hasParent()

Returns whether the builder has a parent.

Return Value

Boolean