@@ -891,13 +891,13 @@ Form Type Guessing
891
891
~~~~~~~~~~~~~~~~~~
892
892
893
893
If the object handled by the form includes validation constraints, Symfony can
894
- introspect that metadata to guess the type of your field and set it up for you .
895
- In the above example, Symfony can guess from the validation rules that both the
894
+ introspect that metadata to guess the type of your field.
895
+ In the above example, Symfony can guess from the validation rules that the
896
896
``task `` field is a normal ``TextType `` field and the ``dueDate `` field is a
897
897
``DateType `` field.
898
898
899
- When building the form , omit the second argument to the ``add() `` method, or
900
- pass ``null `` to it, to enable Symfony's "guessing mechanism" ::
899
+ To enable Symfony's "guessing mechanism" , omit the second argument to the ``add() `` method, or
900
+ pass ``null `` to it::
901
901
902
902
// src/Form/Type/TaskType.php
903
903
namespace App\Form\Type;
@@ -932,23 +932,21 @@ pass ``null`` to it, to enable Symfony's "guessing mechanism"::
932
932
Form Type Options Guessing
933
933
..........................
934
934
935
- When the guessing mechanism is enabled for some field (i.e. you omit or pass
936
- ``null `` as the second argument to ``add() ``), in addition to its form type,
937
- the following options can be guessed too:
935
+ When the guessing mechanism is enabled for some field, in addition to its form type,
936
+ the following options will be guessed too:
938
937
939
938
``required ``
940
- The ``required `` option can be guessed based on the validation rules (i.e. is
939
+ The ``required `` option is guessed based on the validation rules (i.e. is
941
940
the field ``NotBlank `` or ``NotNull ``) or the Doctrine metadata (i.e. is the
942
941
field ``nullable ``). This is very useful, as your client-side validation will
943
942
automatically match your validation rules.
944
943
945
944
``maxlength ``
946
945
If the field is some sort of text field, then the ``maxlength `` option attribute
947
- can be guessed from the validation constraints (if ``Length `` or ``Range `` is used)
946
+ is guessed from the validation constraints (if ``Length `` or ``Range `` is used)
948
947
or from the :doc: `Doctrine </doctrine >` metadata (via the field's length).
949
948
950
- If you'd like to change one of the guessed values, override it by passing the
951
- option in the options field array::
949
+ If you'd like to change one of the guessed values, override it in the options field array::
952
950
953
951
->add('task', null, ['attr' => ['maxlength' => 4]])
954
952
0 commit comments