Class

Symfony\Component\Form\AbstractType

abstract class AbstractType implements FormTypeInterface

Methods

buildForm(FormBuilder $builder, array $options)

Builds the form.

buildView(FormView $view, FormInterface $form)

Builds the form view.

buildViewBottomUp(FormView $view, FormInterface $form)

Builds the form view.

FormBuilder|null createBuilder(string $name, FormFactoryInterface $factory, array $options)

Returns a builder for the current type.

array getDefaultOptions(array $options)

Returns the default options for this type.

array getAllowedOptionValues(array $options)

Returns the allowed option values for each option (if any).

string|null getParent(array $options)

Returns the name of the parent type.

setExtensions(array $extensions)

Adds extensions for this type.

array getExtensions()

Returns the extensions associated with this type.

Details

at line 36
public buildForm(FormBuilder $builder, array $options)

Builds the form.

This method gets called for each type in the hierarchy starting from the top most type. Type extensions can further modify the form.

Parameters

FormBuilder $builder The form builder
array $options The options

See also

FormTypeExtensionInterface::buildForm()

at line 52
public buildView(FormView $view, FormInterface $form)

Builds the form view.

This method gets called for each type in the hierarchy starting from the top most type. Type extensions can further modify the view.

Parameters

FormView $view The view
FormInterface $form The form

See also

FormTypeExtensionInterface::buildView()

at line 71
public buildViewBottomUp(FormView $view, FormInterface $form)

Builds the form view.

This method gets called for each type in the hierarchy starting from the bottommost type. Type extensions can further modify the view.

Children views have been built while this method gets called so you get a chance to modify them.

Parameters

FormView $view The view
FormInterface $form The form

See also

FormTypeExtensionInterface::buildViewBottomUp()

at line 87
public FormBuilder|null createBuilder(string $name, FormFactoryInterface $factory, array $options)

Returns a builder for the current type.

The builder is retrieved by going up in the type hierarchy when a type does not provide one.

Parameters

string $name The name of the builder
FormFactoryInterface $factory The form factory
array $options The options

Return Value

FormBuilder|null A form builder or null when the type does not have a builder

at line 99
public array getDefaultOptions(array $options)

Returns the default options for this type.

Parameters

array $options

Return Value

array The default options

at line 111
public array getAllowedOptionValues(array $options)

Returns the allowed option values for each option (if any).

Parameters

array $options

Return Value

array The allowed option values

at line 123
public string|null getParent(array $options)

Returns the name of the parent type.

Parameters

array $options

Return Value

string|null The name of the parent type if any otherwise null

at line 135
public setExtensions(array $extensions)

Adds extensions for this type.

Parameters

array $extensions An array of FormTypeExtensionInterface

Exceptions

UnexpectedTypeException if any extension does not implement FormTypeExtensionInterface

at line 151
public array getExtensions()

Returns the extensions associated with this type.

Return Value

array An array of FormTypeExtensionInterface