Symfony2 API
Class

Symfony\Component\Form\FormFactory

class FormFactory implements FormFactoryInterface

Methods

__construct(FormRegistryInterface $registry, ResolvedFormTypeFactoryInterface $resolvedTypeFactory)

FormInterface create(string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form.

FormInterface createNamed(string|integer $name, string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form.

FormInterface createForProperty(string $class, string $property, mixed $data = null, array $options = array())

Returns a form for a property of a class.

FormBuilderInterface createBuilder(string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form builder.

FormBuilderInterface createNamedBuilder(string|integer $name, string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form builder.

FormBuilderInterface createBuilderForProperty(string $class, string $property, mixed $data = null, array $options = array())

Returns a form builder for a property of a class.

Details

at line 28
public __construct(FormRegistryInterface $registry, ResolvedFormTypeFactoryInterface $resolvedTypeFactory)

Parameters

FormRegistryInterface $registry
ResolvedFormTypeFactoryInterface $resolvedTypeFactory

at line 37
public FormInterface create(string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form.

Parameters

string|FormTypeInterface $type The type of the form
mixed $data The initial data
array $options The options

Return Value

FormInterface The form named after the type

Exceptions

InvalidOptionsException if any given option is not applicable to the given type

at line 45
public FormInterface createNamed(string|integer $name, string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form.

Parameters

string|integer $name The name of the form
string|FormTypeInterface $type The type of the form
mixed $data The initial data
array $options The options

Return Value

FormInterface The form

Exceptions

InvalidOptionsException if any given option is not applicable to the given type

at line 53
public FormInterface createForProperty(string $class, string $property, mixed $data = null, array $options = array())

Returns a form for a property of a class.

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for
mixed $data The initial data
array $options The options for the builder

Return Value

FormInterface The form named after the property

Exceptions

InvalidOptionsException if any given option is not applicable to the form type

at line 61
public FormBuilderInterface createBuilder(string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form builder.

Parameters

string|FormTypeInterface $type The type of the form
mixed $data The initial data
array $options The options

Return Value

FormBuilderInterface The form builder

Exceptions

InvalidOptionsException if any given option is not applicable to the given type

at line 73
public FormBuilderInterface createNamedBuilder(string|integer $name, string|FormTypeInterface $type = 'form', mixed $data = null, array $options = array())

Returns a form builder.

Parameters

string|integer $name The name of the form
string|FormTypeInterface $type The type of the form
mixed $data The initial data
array $options The options

Return Value

FormBuilderInterface The form builder

Exceptions

InvalidOptionsException if any given option is not applicable to the given type

at line 93
public FormBuilderInterface createBuilderForProperty(string $class, string $property, mixed $data = null, array $options = array())

Returns a form builder for a property of a class.

If any of the 'max_length', 'required' and type options can be guessed, and are not provided in the options argument, the guessed value is used.

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for
mixed $data The initial data
array $options The options for the builder

Return Value

FormBuilderInterface The form builder named after the property

Exceptions

InvalidOptionsException if any given option is not applicable to the form type