W3cubDocs

/Symfony 2.7

Symfony\Component\Form\Extension\Csrf\Type\FormTypeCsrfExtension

class FormTypeCsrfExtension extends AbstractTypeExtension

Methods

buildForm(FormBuilderInterface $builder, array $options)

Adds a CSRF field to the form when the CSRF protection is enabled.

buildView(FormView $view, FormInterface $form, array $options)

Builds the view.

from AbstractTypeExtension
finishView(FormView $view, FormInterface $form, array $options)

Adds a CSRF field to the root form view.

setDefaultOptions(OptionsResolverInterface $resolver)

Overrides the default options from the extended type.

__construct($defaultTokenManager, $defaultEnabled = true, $defaultFieldName = '_token', TranslatorInterface $translator = null, $translationDomain = null)
string getExtendedType()

Returns the name of the type being extended.

Details

public buildForm(FormBuilderInterface $builder, array $options)

Adds a CSRF field to the form when the CSRF protection is enabled.

Parameters

FormBuilderInterface $builder The form builder
array $options The options

public buildView(FormView $view, FormInterface $form, array $options)

Builds the view.

This method is called after the extended type has built the view to further modify it.

Parameters

FormView $view The view
FormInterface $form The form
array $options The options

public finishView(FormView $view, FormInterface $form, array $options)

Adds a CSRF field to the root form view.

Parameters

FormView $view The form view
FormInterface $form The form
array $options The options

public setDefaultOptions(OptionsResolverInterface $resolver)

Overrides the default options from the extended type.

Parameters

OptionsResolverInterface $resolver The resolver for the options.

public __construct($defaultTokenManager, $defaultEnabled = true, $defaultFieldName = '_token', TranslatorInterface $translator = null, $translationDomain = null)

Parameters

$defaultTokenManager
$defaultEnabled
$defaultFieldName
TranslatorInterface $translator
$translationDomain

public string getExtendedType()

Returns the name of the type being extended.

Return Value

string The name of the type being extended

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.html