diff --git a/reference/forms/types/field.rst b/reference/forms/types/field.rst index 20f9cd7412a..59a422d66e7 100644 --- a/reference/forms/types/field.rst +++ b/reference/forms/types/field.rst @@ -9,12 +9,12 @@ functions as the parent field type for many other fields. The ``field`` type predefines a couple of options : -* .. include:: /reference/forms/types/options/data.rst.inc +.. include:: /reference/forms/types/options/data.rst.inc -* .. include:: /reference/forms/types/options/required.rst.inc +.. include:: /reference/forms/types/options/required.rst.inc -* .. include:: /reference/forms/types/options/disabled.rst.inc +.. include:: /reference/forms/types/options/disabled.rst.inc -* .. include:: /reference/forms/types/options/trim.rst.inc +.. include:: /reference/forms/types/options/trim.rst.inc -* .. include:: /reference/forms/types/options/property_path.rst.inc +.. include:: /reference/forms/types/options/property_path.rst.inc diff --git a/reference/forms/types/options/data.rst.inc b/reference/forms/types/options/data.rst.inc new file mode 100644 index 00000000000..260f2d0029d --- /dev/null +++ b/reference/forms/types/options/data.rst.inc @@ -0,0 +1,15 @@ +* ``data`` [type: any, default: the field's initial value] + When you create a form, each field initially displays the value of the + corresponding property of the form's domain object. If you want to override + this initial value, you can set it in the data option. + + .. code-block:: php + + use Symfony\Component\Form\HiddenField + + $field = new HiddenField('token', array( + 'data' => 'abcdef', + )); + assert('abcdef' === $field->getData()); + + diff --git a/reference/forms/types/options/disabled.rst.inc b/reference/forms/types/options/disabled.rst.inc new file mode 100644 index 00000000000..970ba258792 --- /dev/null +++ b/reference/forms/types/options/disabled.rst.inc @@ -0,0 +1,17 @@ +* ``disabled`` [type: Boolean, default: false] + If you don't want a user to modify the value of a field, you can set + the disabled option to true. Any submitted value will be ignored. + + .. code-block:: php + + use Symfony\Component\Form\TextField + + $field = new TextField('status', array( + 'data' => 'Old data', + 'disabled' => true, + )); + $field->submit('New data'); + + assert('Old data' === $field->getData()); + +