class FormBuilder extends FormConfigBuilder implements IteratorAggregate, FormBuilderInterface
A builder for creating {@link Form} instances.
Methods
|
__construct(string $name, string $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array())
Creates an empty form configuration. |
||
| FormConfigBuilderInterface |
addEventListener(string $eventName, callable $listener, integer $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, Boolean $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, Boolean $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 |
| Boolean |
getMapped()
Returns whether the form should be mapped to an element of its parent's data. |
from FormConfigBuilder |
| Boolean |
getByReference()
Returns whether the form's data should be modified by reference. |
from FormConfigBuilder |
| Boolean |
getInheritData()
Returns whether the form should read and write the data of its parent. |
from FormConfigBuilder |
| FormConfigBuilder |
getVirtual()
Alias of {@link getInheritData()}. |
from FormConfigBuilder |
| Boolean |
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 |
| Boolean |
getRequired()
Returns whether the form is required. |
from FormConfigBuilder |
| Boolean |
getDisabled()
Returns whether the form is disabled. |
from FormConfigBuilder |
| Boolean |
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 |
| Boolean |
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 |
| Boolean |
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 |
| Boolean |
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 |
| Boolean |
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, string $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(Boolean $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(Boolean $errorBubbling)
Sets whether errors bubble up to the parent. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setRequired(Boolean $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(Boolean $mapped)
Sets whether the form should be mapped to an element of its parent's data. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setByReference(Boolean $byReference)
Sets whether the form's data should be modified by reference. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setInheritData(Boolean $inheritData)
Sets whether the form should read and write the data of its parent. |
from FormConfigBuilder |
| FormConfigBuilder |
setVirtual(Boolean $inheritData)
Alias of {@link setInheritData()}. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setCompound(Boolean $compound)
Sets whether the form should be compound. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setType(ResolvedFormTypeInterface $type)
Set the types. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setData(array $data)
Sets the initial data of the form. |
from FormConfigBuilder |
| FormConfigBuilderInterface |
setDataLocked(Boolean $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(Boolean $initialize)
Sets whether the form should be initialized automatically. |
from FormConfigBuilder |
| FormConfigInterface |
getFormConfig()
Builds and returns the form configuration. |
|
| static |
validateName(string|integer $name)
Validates whether the given variable is a valid form name. |
from FormConfigBuilder |
| static Boolean |
isValidName(string $name)
Returns whether the given variable contains a valid form name. |
from FormConfigBuilder |
| FormBuilderInterface |
add(string|integer|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. |
|
|
count()
{@inheritdoc} |
||
| Form |
getForm()
Creates the form. |
|
|
getIterator()
{@inheritdoc} |
Details
at line 49
public
__construct(string $name, string $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array())
Creates an empty form configuration.
in FormConfigBuilder at line 208
public FormConfigBuilderInterface
addEventListener(string $eventName, callable $listener, integer $priority)
Adds an event listener to an event on this form.
in FormConfigBuilder at line 222
public FormConfigBuilderInterface
addEventSubscriber(EventSubscriberInterface $subscriber)
Adds an event subscriber for events on this form.
in FormConfigBuilder at line 236
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.
in FormConfigBuilder at line 254
public FormConfigBuilderInterface
resetViewTransformers()
Clears the view transformers.
in FormConfigBuilder at line 268
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.
in FormConfigBuilder at line 286
public FormConfigBuilderInterface
resetModelTransformers()
Clears the normalization transformers.
in FormConfigBuilder at line 300
public EventDispatcherInterface
getEventDispatcher()
Returns the event dispatcher used to dispatch form events.
in FormConfigBuilder at line 312
public string
getName()
Returns the name of the form used as HTTP parameter.
in FormConfigBuilder at line 320
public null|PropertyPathInterface
getPropertyPath()
Returns the property path that the form should be mapped to.
in FormConfigBuilder at line 328
public Boolean
getMapped()
Returns whether the form should be mapped to an element of its parent's data.
in FormConfigBuilder at line 336
public Boolean
getByReference()
Returns whether the form's data should be modified by reference.
in FormConfigBuilder at line 344
public Boolean
getInheritData()
Returns whether the form should read and write the data of its parent.
in FormConfigBuilder at line 357
public FormConfigBuilder
getVirtual()
Alias of {@link getInheritData()}.
in FormConfigBuilder at line 368
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.
in FormConfigBuilder at line 376
public ResolvedFormTypeInterface
getType()
Returns the form types used to construct the form.
in FormConfigBuilder at line 384
public DataTransformerInterface[]
getViewTransformers()
Returns the view transformers of the form.
in FormConfigBuilder at line 392
public DataTransformerInterface[]
getModelTransformers()
Returns the model transformers of the form.
in FormConfigBuilder at line 400
public DataMapperInterface
getDataMapper()
Returns the data mapper of the form.
in FormConfigBuilder at line 408
public Boolean
getRequired()
Returns whether the form is required.
in FormConfigBuilder at line 416
public Boolean
getDisabled()
Returns whether the form is disabled.
in FormConfigBuilder at line 424
public Boolean
getErrorBubbling()
Returns whether errors attached to the form will bubble to its parent.
in FormConfigBuilder at line 432
public mixed
getEmptyData()
Returns the data that should be returned when the form is empty.
in FormConfigBuilder at line 440
public array
getAttributes()
Returns additional attributes of the form.
in FormConfigBuilder at line 448
public Boolean
hasAttribute(string $name)
Returns whether the attribute with the given name exists.
in FormConfigBuilder at line 456
public mixed
getAttribute(string $name, mixed $default = null)
Returns the value of the given attribute.
in FormConfigBuilder at line 464
public mixed
getData()
Returns the initial data of the form.
in FormConfigBuilder at line 472
public string
getDataClass()
Returns the class of the form data or null if the data is scalar or an array.
in FormConfigBuilder at line 480
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
submitting the form.
in FormConfigBuilder at line 488
public FormFactoryInterface
getFormFactory()
Returns the form factory used for creating new forms.
in FormConfigBuilder at line 496
public string
getAction()
Returns the target URL of the form.
in FormConfigBuilder at line 504
public string
getMethod()
Returns the HTTP method used by the form.
in FormConfigBuilder at line 512
public RequestHandlerInterface
getRequestHandler()
Returns the request handler used by the form.
in FormConfigBuilder at line 527
public Boolean
getAutoInitialize()
Returns whether the form should be initialized upon creation.
in FormConfigBuilder at line 535
public array
getOptions()
Returns all options passed during the construction of the form.
in FormConfigBuilder at line 543
public Boolean
hasOption(string $name)
Returns whether a specific option exists.
in FormConfigBuilder at line 551
public mixed
getOption(string $name, mixed $default = null)
Returns the value of a specific option.
in FormConfigBuilder at line 559
public FormConfigBuilderInterface
setAttribute(string $name, string $value)
Sets the value for an attribute.
in FormConfigBuilder at line 573
public FormConfigBuilderInterface
setAttributes(array $attributes)
Sets the attributes.
in FormConfigBuilder at line 587
public FormConfigBuilderInterface
setDataMapper(DataMapperInterface $dataMapper = null)
Sets the data mapper used by the form.
in FormConfigBuilder at line 601
public FormConfigBuilderInterface
setDisabled(Boolean $disabled)
Set whether the form is disabled.
in FormConfigBuilder at line 615
public FormConfigBuilderInterface
setEmptyData(mixed $emptyData)
Sets the data used for the client data when no value is submitted.
in FormConfigBuilder at line 629
public FormConfigBuilderInterface
setErrorBubbling(Boolean $errorBubbling)
Sets whether errors bubble up to the parent.
in FormConfigBuilder at line 643
public FormConfigBuilderInterface
setRequired(Boolean $required)
Sets whether this field is required to be filled out when submitted.
in FormConfigBuilder at line 657
public FormConfigBuilderInterface
setPropertyPath(null|string|PropertyPathInterface $propertyPath)
Sets the property path that the form should be mapped to.
in FormConfigBuilder at line 675
public FormConfigBuilderInterface
setMapped(Boolean $mapped)
Sets whether the form should be mapped to an element of its parent's data.
in FormConfigBuilder at line 689
public FormConfigBuilderInterface
setByReference(Boolean $byReference)
Sets whether the form's data should be modified by reference.
in FormConfigBuilder at line 703
public FormConfigBuilderInterface
setInheritData(Boolean $inheritData)
Sets whether the form should read and write the data of its parent.
in FormConfigBuilder at line 724
public FormConfigBuilder
setVirtual(Boolean $inheritData)
Alias of {@link setInheritData()}.
in FormConfigBuilder at line 735
public FormConfigBuilderInterface
setCompound(Boolean $compound)
Sets whether the form should be compound.
in FormConfigBuilder at line 749
public FormConfigBuilderInterface
setType(ResolvedFormTypeInterface $type)
Set the types.
in FormConfigBuilder at line 763
public FormConfigBuilderInterface
setData(array $data)
Sets the initial data of the form.
in FormConfigBuilder at line 777
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
submitting the form.
in FormConfigBuilder at line 791
public
setFormFactory(FormFactoryInterface $formFactory)
Sets the form factory used for creating new forms.
in FormConfigBuilder at line 805
public FormConfigBuilderInterface
setAction(string $action)
Sets the target URL of the form.
in FormConfigBuilder at line 819
public FormConfigBuilderInterface
setMethod(string $method)
Sets the HTTP method used by the form.
in FormConfigBuilder at line 843
public FormConfigBuilderInterface
setRequestHandler(RequestHandlerInterface $requestHandler)
Sets the request handler used by the form.
in FormConfigBuilder at line 857
public FormConfigBuilderInterface
setAutoInitialize(Boolean $initialize)
Sets whether the form should be initialized automatically.
Should be set to true only for root forms.
at line 199
public FormConfigInterface
getFormConfig()
Builds and returns the form configuration.
in FormConfigBuilder at line 888
static public
validateName(string|integer $name)
Validates whether the given variable is a valid form name.
in FormConfigBuilder at line 916
static public Boolean
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 (":")
at line 59
public FormBuilderInterface
add(string|integer|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.
at line 95
public FormBuilderInterface
create(string $name, string|FormTypeInterface $type = null, array $options = array())
Creates a form builder.
at line 115
public FormBuilderInterface
get(string $name)
Returns a child by name.
at line 135
public FormBuilderInterface
remove(string $name)
Removes the field with the given name.
at line 153
public Boolean
has(string $name)
Returns whether a field with the given name exists.
at line 173
public array
all()
Returns the children.
at line 187
public
count()
{@inheritdoc}
at line 212
public Form
getForm()
Creates the form.
at line 238
public
getIterator()
{@inheritdoc}