FormConfigBuilder
class FormConfigBuilder implements FormConfigBuilderInterface
A basic form configuration.
Methods
Creates an empty form configuration.
Adds an event listener to an event on this form.
Adds an event subscriber for events on this form.
Appends / prepends a transformer to the view transformer chain.
Clears the view transformers.
Prepends / appends a transformer to the normalization transformer chain.
Clears the normalization transformers.
Returns the event dispatcher used to dispatch form events.
Returns the name of the form used as HTTP parameter.
Returns the property path that the form should be mapped to.
Returns whether the form should be mapped to an element of its parent's data.
Returns whether the form's data should be modified by reference.
Returns whether the form should read and write the data of its parent.
Returns whether the form is compound.
Returns the form types used to construct the form.
Returns the view transformers of the form.
Returns the model transformers of the form.
Returns the data mapper of the form.
Returns whether the form is required.
Returns whether the form is disabled.
Returns whether errors attached to the form will bubble to its parent.
Returns the data that should be returned when the form is empty.
Returns additional attributes of the form.
Returns whether the attribute with the given name exists.
Returns the value of the given attribute.
Returns the initial data of the form.
Returns the class of the form data or null if the data is scalar or an array.
Returns whether the form's data is locked.
Returns the form factory used for creating new forms.
Returns the target URL of the form.
Returns the HTTP method used by the form.
Returns the request handler used by the form.
Returns whether the form should be initialized upon creation.
Returns all options passed during the construction of the form.
Returns whether a specific option exists.
Returns the value of a specific option.
Sets the value for an attribute.
Sets the attributes.
Set whether the form is disabled.
Sets the data used for the client data when no value is submitted.
Sets whether errors bubble up to the parent.
Sets whether this field is required to be filled out when submitted.
Sets the property path that the form should be mapped to.
Sets whether the form should be mapped to an element of its parent's data.
Sets whether the form's data should be modified by reference.
Sets whether the form should read and write the data of its parent.
Sets whether the form should be compound.
Sets the initial data of the form.
Locks the form's data to the data passed in the configuration.
Sets the form factory used for creating new forms.
Sets the target URL of the form.
Sets the HTTP method used by the form.
Sets the request handler used by the form.
Sets whether the form should be initialized automatically.
Builds and returns the form configuration.
Validates whether the given variable is a valid form name.
Returns whether the given variable contains a valid form name.
Details
at line line 191
__construct(string|int $name, string $dataClass, EventDispatcherInterface $dispatcher, array $options = array())
Creates an empty form configuration.
at line line 208
FormConfigBuilderInterface
addEventListener(string $eventName, callable $listener, int $priority)
Adds an event listener to an event on this form.
at line line 222
FormConfigBuilderInterface
addEventSubscriber(EventSubscriberInterface $subscriber)
Adds an event subscriber for events on this form.
at line line 236
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.
at line line 254
FormConfigBuilderInterface
resetViewTransformers()
Clears the view transformers.
at line line 268
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.
at line line 286
FormConfigBuilderInterface
resetModelTransformers()
Clears the normalization transformers.
at line line 300
EventDispatcherInterface
getEventDispatcher()
Returns the event dispatcher used to dispatch form events.
at line line 312
string
getName()
Returns the name of the form used as HTTP parameter.
at line line 320
null|PropertyPathInterface
getPropertyPath()
Returns the property path that the form should be mapped to.
at line line 328
bool
getMapped()
Returns whether the form should be mapped to an element of its parent's data.
at line line 336
bool
getByReference()
Returns whether the form's data should be modified by reference.
at line line 344
bool
getInheritData()
Returns whether the form should read and write the data of its parent.
at line line 352
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.
at line line 360
ResolvedFormTypeInterface
getType()
Returns the form types used to construct the form.
at line line 368
DataTransformerInterface[]
getViewTransformers()
Returns the view transformers of the form.
at line line 376
DataTransformerInterface[]
getModelTransformers()
Returns the model transformers of the form.
at line line 384
DataMapperInterface
getDataMapper()
Returns the data mapper of the form.
at line line 392
bool
getRequired()
Returns whether the form is required.
at line line 400
bool
getDisabled()
Returns whether the form is disabled.
at line line 408
bool
getErrorBubbling()
Returns whether errors attached to the form will bubble to its parent.
at line line 416
mixed
getEmptyData()
Returns the data that should be returned when the form is empty.
at line line 424
array
getAttributes()
Returns additional attributes of the form.
at line line 432
bool
hasAttribute(string $name)
Returns whether the attribute with the given name exists.
at line line 440
mixed
getAttribute(string $name, mixed $default = null)
Returns the value of the given attribute.
at line line 448
mixed
getData()
Returns the initial data of the form.
at line line 456
string
getDataClass()
Returns the class of the form data or null if the data is scalar or an array.
at line line 464
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.
at line line 472
FormFactoryInterface
getFormFactory()
Returns the form factory used for creating new forms.
at line line 480
string
getAction()
Returns the target URL of the form.
at line line 488
string
getMethod()
Returns the HTTP method used by the form.
at line line 496
RequestHandlerInterface
getRequestHandler()
Returns the request handler used by the form.
at line line 511
bool
getAutoInitialize()
Returns whether the form should be initialized upon creation.
at line line 519
array
getOptions()
Returns all options passed during the construction of the form.
at line line 527
bool
hasOption(string $name)
Returns whether a specific option exists.
at line line 535
mixed
getOption(string $name, mixed $default = null)
Returns the value of a specific option.
at line line 543
FormConfigBuilderInterface
setAttribute(string $name, mixed $value)
Sets the value for an attribute.
at line line 557
FormConfigBuilderInterface
setAttributes(array $attributes)
Sets the attributes.
at line line 571
FormConfigBuilderInterface
setDataMapper(DataMapperInterface $dataMapper = null)
Sets the data mapper used by the form.
at line line 585
FormConfigBuilderInterface
setDisabled(bool $disabled)
Set whether the form is disabled.
at line line 599
FormConfigBuilderInterface
setEmptyData(mixed $emptyData)
Sets the data used for the client data when no value is submitted.
at line line 613
FormConfigBuilderInterface
setErrorBubbling(bool $errorBubbling)
Sets whether errors bubble up to the parent.
at line line 627
FormConfigBuilderInterface
setRequired(bool $required)
Sets whether this field is required to be filled out when submitted.
at line line 641
FormConfigBuilderInterface
setPropertyPath(null|string|PropertyPathInterface $propertyPath)
Sets the property path that the form should be mapped to.
at line line 659
FormConfigBuilderInterface
setMapped(bool $mapped)
Sets whether the form should be mapped to an element of its parent's data.
at line line 673
FormConfigBuilderInterface
setByReference(bool $byReference)
Sets whether the form's data should be modified by reference.
at line line 687
FormConfigBuilderInterface
setInheritData(bool $inheritData)
Sets whether the form should read and write the data of its parent.
at line line 701
FormConfigBuilderInterface
setCompound(bool $compound)
Sets whether the form should be compound.
at line line 715
FormConfigBuilderInterface
setType(ResolvedFormTypeInterface $type)
Set the types.
at line line 729
FormConfigBuilderInterface
setData(mixed $data)
Sets the initial data of the form.
at line line 743
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.
at line line 757
setFormFactory(FormFactoryInterface $formFactory)
Sets the form factory used for creating new forms.
at line line 771
FormConfigBuilderInterface
setAction(string $action)
Sets the target URL of the form.
at line line 785
FormConfigBuilderInterface
setMethod(string $method)
Sets the HTTP method used by the form.
at line line 809
FormConfigBuilderInterface
setRequestHandler(RequestHandlerInterface $requestHandler)
Sets the request handler used by the form.
at line line 823
FormConfigBuilderInterface
setAutoInitialize(bool $initialize)
Sets whether the form should be initialized automatically.
Should be set to true only for root forms.
at line line 837
FormConfigInterface
getFormConfig()
Builds and returns the form configuration.
at line line 858
static
validateName(string|int $name)
Validates whether the given variable is a valid form name.
at line line 886
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 (":")