csrf Field Type

Edit this page

Warning: You are browsing the documentation for Symfony 2.0, which is no longer maintained.

Read the updated version of this page for Symfony 6.1 (the current stable version).

csrf Field Type

The csrf type is a hidden input field containing a CSRF token.

Rendered as input hidden field
  • csrf_provider
  • intention
Overridden Options
  • property_path
Parent type hidden
Class CsrfType

Overridden Options


default: false

A Csrf field must not be mapped to the object, so this option defaults to false.

Field Options


type: Symfony\Component\Form\CsrfProvider\CsrfProviderInterface

The CsrfProviderInterface object that should generate the CSRF token. If not set, this defaults to the default provider.


type: string

An optional unique identifier used to generate the CSRF token.


type: any default: the field's value

Fields display a property value of the form's domain object by default. When the form is submitted, the submitted value is written back into the object.

If you want to override the property that a field reads from and writes to,
you can set the property_path option. Its default value is the field's name.

If you wish the field to be ignored when reading or writing to the object
you can set the property_path option to false

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.