@@ -840,13 +840,13 @@ Form Type Guessing
840
840
~~~~~~~~~~~~~~~~~~
841
841
842
842
If the object handled by the form includes validation constraints, Symfony can
843
- introspect that metadata to guess the type of your field and set it up for you .
844
- In the above example, Symfony can guess from the validation rules that both the
843
+ introspect that metadata to guess the type of your field.
844
+ In the above example, Symfony can guess from the validation rules that the
845
845
``task `` field is a normal ``TextType `` field and the ``dueDate `` field is a
846
846
``DateType `` field.
847
847
848
- When building the form , omit the second argument to the ``add() `` method, or
849
- pass ``null `` to it, to enable Symfony's "guessing mechanism" ::
848
+ To enable Symfony's "guessing mechanism" , omit the second argument to the ``add() `` method, or
849
+ pass ``null `` to it::
850
850
851
851
// src/Form/Type/TaskType.php
852
852
namespace App\Form\Type;
@@ -881,23 +881,21 @@ pass ``null`` to it, to enable Symfony's "guessing mechanism"::
881
881
Form Type Options Guessing
882
882
..........................
883
883
884
- When the guessing mechanism is enabled for some field (i.e. you omit or pass
885
- ``null `` as the second argument to ``add() ``), in addition to its form type,
886
- the following options can be guessed too:
884
+ When the guessing mechanism is enabled for some field, in addition to its form type,
885
+ the following options will be guessed too:
887
886
888
887
``required ``
889
- The ``required `` option can be guessed based on the validation rules (i.e. is
888
+ The ``required `` option is guessed based on the validation rules (i.e. is
890
889
the field ``NotBlank `` or ``NotNull ``) or the Doctrine metadata (i.e. is the
891
890
field ``nullable ``). This is very useful, as your client-side validation will
892
891
automatically match your validation rules.
893
892
894
893
``maxlength ``
895
894
If the field is some sort of text field, then the ``maxlength `` option attribute
896
- can be guessed from the validation constraints (if ``Length `` or ``Range `` is used)
895
+ is guessed from the validation constraints (if ``Length `` or ``Range `` is used)
897
896
or from the :doc: `Doctrine </doctrine >` metadata (via the field's length).
898
897
899
- If you'd like to change one of the guessed values, override it by passing the
900
- option in the options field array::
898
+ If you'd like to change one of the guessed values, override it in the options field array::
901
899
902
900
->add('task', null, ['attr' => ['maxlength' => 4]])
903
901
0 commit comments