@@ -872,13 +872,13 @@ Form Type Guessing
872
872
~~~~~~~~~~~~~~~~~~
873
873
874
874
If the object handled by the form includes validation constraints, Symfony can
875
- introspect that metadata to guess the type of your field and set it up for you .
876
- In the above example, Symfony can guess from the validation rules that both the
875
+ introspect that metadata to guess the type of your field.
876
+ In the above example, Symfony can guess from the validation rules that the
877
877
``task `` field is a normal ``TextType `` field and the ``dueDate `` field is a
878
878
``DateType `` field.
879
879
880
- When building the form , omit the second argument to the ``add() `` method, or
881
- pass ``null `` to it, to enable Symfony's "guessing mechanism" ::
880
+ To enable Symfony's "guessing mechanism" , omit the second argument to the ``add() `` method, or
881
+ pass ``null `` to it::
882
882
883
883
// src/Form/Type/TaskType.php
884
884
namespace App\Form\Type;
@@ -913,23 +913,21 @@ pass ``null`` to it, to enable Symfony's "guessing mechanism"::
913
913
Form Type Options Guessing
914
914
..........................
915
915
916
- When the guessing mechanism is enabled for some field (i.e. you omit or pass
917
- ``null `` as the second argument to ``add() ``), in addition to its form type,
918
- the following options can be guessed too:
916
+ When the guessing mechanism is enabled for some field, in addition to its form type,
917
+ the following options will be guessed too:
919
918
920
919
``required ``
921
- The ``required `` option can be guessed based on the validation rules (i.e. is
920
+ The ``required `` option is guessed based on the validation rules (i.e. is
922
921
the field ``NotBlank `` or ``NotNull ``) or the Doctrine metadata (i.e. is the
923
922
field ``nullable ``). This is very useful, as your client-side validation will
924
923
automatically match your validation rules.
925
924
926
925
``maxlength ``
927
926
If the field is some sort of text field, then the ``maxlength `` option attribute
928
- can be guessed from the validation constraints (if ``Length `` or ``Range `` is used)
927
+ is guessed from the validation constraints (if ``Length `` or ``Range `` is used)
929
928
or from the :doc: `Doctrine </doctrine >` metadata (via the field's length).
930
929
931
- If you'd like to change one of the guessed values, override it by passing the
932
- option in the options field array::
930
+ If you'd like to change one of the guessed values, override it in the options field array::
933
931
934
932
->add('task', null, ['attr' => ['maxlength' => 4]])
935
933
0 commit comments