class FormBuilder extends FormConfigBuilder implements IteratorAggregate, FormBuilderInterface
A builder for creating {@link Form} instances.
Methods
__construct(string|int $name, string $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array()) Creates a new form builder. | ||
FormConfigBuilderInterface | addEventListener(string $eventName, callable $listener, int $priority) Adds an event listener to an event on this form. | from FormConfigBuilder |
FormConfigBuilderInterface | addEventSubscriber(EventSubscriberInterface $subscriber) Adds an event subscriber for events on this form. | from FormConfigBuilder |
FormConfigBuilderInterface | addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false) Appends / prepends a transformer to the view transformer chain. | from FormConfigBuilder |
FormConfigBuilderInterface | resetViewTransformers() Clears the view transformers. | from FormConfigBuilder |
FormConfigBuilderInterface | addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false) Prepends / appends a transformer to the normalization transformer chain. | from FormConfigBuilder |
FormConfigBuilderInterface | resetModelTransformers() Clears the normalization transformers. | from FormConfigBuilder |
EventDispatcherInterface | getEventDispatcher() Returns the event dispatcher used to dispatch form events. | from FormConfigBuilder |
string | getName() Returns the name of the form used as HTTP parameter. | from FormConfigBuilder |
null|PropertyPathInterface | getPropertyPath() Returns the property path that the form should be mapped to. | from FormConfigBuilder |
bool | getMapped() Returns whether the form should be mapped to an element of its parent's data. | from FormConfigBuilder |
bool | getByReference() Returns whether the form's data should be modified by reference. | from FormConfigBuilder |
bool | getInheritData() Returns whether the form should read and write the data of its parent. | from FormConfigBuilder |
bool | getCompound() Returns whether the form is compound. | from FormConfigBuilder |
ResolvedFormTypeInterface | getType() Returns the form types used to construct the form. | from FormConfigBuilder |
DataTransformerInterface[] | getViewTransformers() Returns the view transformers of the form. | from FormConfigBuilder |
DataTransformerInterface[] | getModelTransformers() Returns the model transformers of the form. | from FormConfigBuilder |
DataMapperInterface | getDataMapper() Returns the data mapper of the form. | from FormConfigBuilder |
bool | getRequired() Returns whether the form is required. | from FormConfigBuilder |
bool | getDisabled() Returns whether the form is disabled. | from FormConfigBuilder |
bool | getErrorBubbling() Returns whether errors attached to the form will bubble to its parent. | from FormConfigBuilder |
mixed | getEmptyData() Returns the data that should be returned when the form is empty. | from FormConfigBuilder |
array | getAttributes() Returns additional attributes of the form. | from FormConfigBuilder |
bool | hasAttribute(string $name) Returns whether the attribute with the given name exists. | from FormConfigBuilder |
mixed | getAttribute(string $name, mixed $default = null) Returns the value of the given attribute. | from FormConfigBuilder |
mixed | getData() Returns the initial data of the form. | from FormConfigBuilder |
string | getDataClass() Returns the class of the form data or null if the data is scalar or an array. | from FormConfigBuilder |
bool | getDataLocked() Returns whether the form's data is locked. | from FormConfigBuilder |
FormFactoryInterface | getFormFactory() Returns the form factory used for creating new forms. | from FormConfigBuilder |
string | getAction() Returns the target URL of the form. | from FormConfigBuilder |
string | getMethod() Returns the HTTP method used by the form. | from FormConfigBuilder |
RequestHandlerInterface | getRequestHandler() Returns the request handler used by the form. | from FormConfigBuilder |
bool | getAutoInitialize() Returns whether the form should be initialized upon creation. | from FormConfigBuilder |
array | getOptions() Returns all options passed during the construction of the form. | from FormConfigBuilder |
bool | hasOption(string $name) Returns whether a specific option exists. | from FormConfigBuilder |
mixed | getOption(string $name, mixed $default = null) Returns the value of a specific option. | from FormConfigBuilder |
FormConfigBuilderInterface | setAttribute(string $name, mixed $value) Sets the value for an attribute. | from FormConfigBuilder |
FormConfigBuilderInterface | setAttributes(array $attributes) Sets the attributes. | from FormConfigBuilder |
FormConfigBuilderInterface | setDataMapper(DataMapperInterface $dataMapper = null) Sets the data mapper used by the form. | from FormConfigBuilder |
FormConfigBuilderInterface | setDisabled(bool $disabled) Set whether the form is disabled. | from FormConfigBuilder |
FormConfigBuilderInterface | setEmptyData(mixed $emptyData) Sets the data used for the client data when no value is submitted. | from FormConfigBuilder |
FormConfigBuilderInterface | setErrorBubbling(bool $errorBubbling) Sets whether errors bubble up to the parent. | from FormConfigBuilder |
FormConfigBuilderInterface | setRequired(bool $required) Sets whether this field is required to be filled out when submitted. | from FormConfigBuilder |
FormConfigBuilderInterface | setPropertyPath(null|string|PropertyPathInterface $propertyPath) Sets the property path that the form should be mapped to. | from FormConfigBuilder |
FormConfigBuilderInterface | setMapped(bool $mapped) Sets whether the form should be mapped to an element of its parent's data. | from FormConfigBuilder |
FormConfigBuilderInterface | setByReference(bool $byReference) Sets whether the form's data should be modified by reference. | from FormConfigBuilder |
FormConfigBuilderInterface | setInheritData(bool $inheritData) Sets whether the form should read and write the data of its parent. | from FormConfigBuilder |
FormConfigBuilderInterface | setCompound(bool $compound) Sets whether the form should be compound. | from FormConfigBuilder |
FormConfigBuilderInterface | setType(ResolvedFormTypeInterface $type) Set the types. | from FormConfigBuilder |
FormConfigBuilderInterface | setData(mixed $data) Sets the initial data of the form. | from FormConfigBuilder |
FormConfigBuilderInterface | setDataLocked(bool $locked) Locks the form's data to the data passed in the configuration. | from FormConfigBuilder |
setFormFactory(FormFactoryInterface $formFactory) Sets the form factory used for creating new forms. | from FormConfigBuilder | |
FormConfigBuilderInterface | setAction(string $action) Sets the target URL of the form. | from FormConfigBuilder |
FormConfigBuilderInterface | setMethod(string $method) Sets the HTTP method used by the form. | from FormConfigBuilder |
FormConfigBuilderInterface | setRequestHandler(RequestHandlerInterface $requestHandler) Sets the request handler used by the form. | from FormConfigBuilder |
FormConfigBuilderInterface | setAutoInitialize(bool $initialize) Sets whether the form should be initialized automatically. | from FormConfigBuilder |
FormConfigInterface | getFormConfig() Builds and returns the form configuration. | |
static | validateName(string|int $name) Validates whether the given variable is a valid form name. | from FormConfigBuilder |
static bool | isValidName(string $name) Returns whether the given variable contains a valid form name. | from FormConfigBuilder |
FormBuilderInterface | add(string|int|FormBuilderInterface $child, string|null $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. | |
FormBuilderInterface | create(string $name, string|null $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. | |
bool | has(string $name) Returns whether a field with the given name exists. | |
array | all() Returns the children. | |
count() {@inheritdoc} | ||
FormInterface | getForm() Creates the form. | |
FormBuilderInterface[] | getIterator() {@inheritdoc} |
Details
__construct(string|int $name, string $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array())
Creates a new form builder.
FormConfigBuilderInterface addEventListener(string $eventName, callable $listener, int $priority)
Adds an event listener to an event on this form.
FormConfigBuilderInterface addEventSubscriber(EventSubscriberInterface $subscriber)
Adds an event subscriber for events on this form.
FormConfigBuilderInterface addViewTransformer(DataTransformerInterface $viewTransformer, bool $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.
FormConfigBuilderInterface resetViewTransformers()
Clears the view transformers.
FormConfigBuilderInterface addModelTransformer(DataTransformerInterface $modelTransformer, bool $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.
FormConfigBuilderInterface resetModelTransformers()
Clears the normalization transformers.
EventDispatcherInterface getEventDispatcher()
Returns the event dispatcher used to dispatch form events.
string getName()
Returns the name of the form used as HTTP parameter.
null|PropertyPathInterface getPropertyPath()
Returns the property path that the form should be mapped to.
bool getMapped()
Returns whether the form should be mapped to an element of its parent's data.
bool getByReference()
Returns whether the form's data should be modified by reference.
bool getInheritData()
Returns whether the form should read and write the data of its parent.
bool 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.
ResolvedFormTypeInterface getType()
Returns the form types used to construct the form.
DataTransformerInterface[] getViewTransformers()
Returns the view transformers of the form.
DataTransformerInterface[] getModelTransformers()
Returns the model transformers of the form.
DataMapperInterface getDataMapper()
Returns the data mapper of the form.
bool getRequired()
Returns whether the form is required.
bool getDisabled()
Returns whether the form is disabled.
bool getErrorBubbling()
Returns whether errors attached to the form will bubble to its parent.
mixed getEmptyData()
Returns the data that should be returned when the form is empty.
array getAttributes()
Returns additional attributes of the form.
bool hasAttribute(string $name)
Returns whether the attribute with the given name exists.
mixed getAttribute(string $name, mixed $default = null)
Returns the value of the given attribute.
mixed getData()
Returns the initial data of the form.
string getDataClass()
Returns the class of the form data or null if the data is scalar or an array.
bool 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 submitting the form.
FormFactoryInterface getFormFactory()
Returns the form factory used for creating new forms.
string getAction()
Returns the target URL of the form.
string getMethod()
Returns the HTTP method used by the form.
RequestHandlerInterface getRequestHandler()
Returns the request handler used by the form.
bool getAutoInitialize()
Returns whether the form should be initialized upon creation.
array getOptions()
Returns all options passed during the construction of the form.
bool hasOption(string $name)
Returns whether a specific option exists.
mixed getOption(string $name, mixed $default = null)
Returns the value of a specific option.
FormConfigBuilderInterface setAttribute(string $name, mixed $value)
Sets the value for an attribute.
FormConfigBuilderInterface setAttributes(array $attributes)
Sets the attributes.
FormConfigBuilderInterface setDataMapper(DataMapperInterface $dataMapper = null)
Sets the data mapper used by the form.
FormConfigBuilderInterface setDisabled(bool $disabled)
Set whether the form is disabled.
FormConfigBuilderInterface setEmptyData(mixed $emptyData)
Sets the data used for the client data when no value is submitted.
FormConfigBuilderInterface setErrorBubbling(bool $errorBubbling)
Sets whether errors bubble up to the parent.
FormConfigBuilderInterface setRequired(bool $required)
Sets whether this field is required to be filled out when submitted.
FormConfigBuilderInterface setPropertyPath(null|string|PropertyPathInterface $propertyPath)
Sets the property path that the form should be mapped to.
FormConfigBuilderInterface setMapped(bool $mapped)
Sets whether the form should be mapped to an element of its parent's data.
FormConfigBuilderInterface setByReference(bool $byReference)
Sets whether the form's data should be modified by reference.
FormConfigBuilderInterface setInheritData(bool $inheritData)
Sets whether the form should read and write the data of its parent.
FormConfigBuilderInterface setCompound(bool $compound)
Sets whether the form should be compound.
FormConfigBuilderInterface setType(ResolvedFormTypeInterface $type)
Set the types.
FormConfigBuilderInterface setData(mixed $data)
Sets the initial data of the form.
FormConfigBuilderInterface setDataLocked(bool $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 submitting the form.
setFormFactory(FormFactoryInterface $formFactory)
Sets the form factory used for creating new forms.
FormConfigBuilderInterface setAction(string $action)
Sets the target URL of the form.
FormConfigBuilderInterface setMethod(string $method)
Sets the HTTP method used by the form.
FormConfigBuilderInterface setRequestHandler(RequestHandlerInterface $requestHandler)
Sets the request handler used by the form.
FormConfigBuilderInterface setAutoInitialize(bool $initialize)
Sets whether the form should be initialized automatically.
Should be set to true only for root forms.
FormConfigInterface getFormConfig()
Builds and returns the form configuration.
static validateName(string|int $name)
Validates whether the given variable is a valid form name.
static bool isValidName(string $name)
Returns whether the given variable contains a valid form name.
A name is accepted if it
- is empty
- starts with a letter, digit or underscore
- contains only letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":")
FormBuilderInterface add(string|int|FormBuilderInterface $child, string|null $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.
FormBuilderInterface create(string $name, string|null $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.
bool has(string $name)
Returns whether a field with the given name exists.
array all()
Returns the children.
count()
{@inheritdoc}
FormInterface getForm()
Creates the form.
FormBuilderInterface[] getIterator()
{@inheritdoc}
Please login to continue.