hidden Field Type

WARNING: You are browsing the documentation for Symfony 2.0 which is not maintained anymore. Consider upgrading your projects to Symfony 3.3.

hidden Field Type

The hidden type represents a hidden input field.

Rendered as input hidden field
Overridden Options
Inherited options
Parent type field
Class HiddenType

Overridden Options

required

default: false

Hidden fields cannot have a required attribute.

error_bubbling

default: true

Pass errors to the root form, otherwise they will not be visible.

Inherited Options

These options inherit from the field type:

data

type: mixed default: Defaults to field of the underlying object (if there is one)

When you create a form, each field initially displays the value of the corresponding property of the form's domain object (if an object is bound to the form). If you want to override the initial value for the form or just an individual field, you can set it in the data option:

1
2
3
$builder->add('token', 'hidden', array(
    'data' => 'abcdef',
));

property_path

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.