Skip to content

Commit b274cfc

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: [Form] Improve form type guessers section
2 parents 41b87a7 + 9aef409 commit b274cfc

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

form/type_guesser.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ type guessers.
1313
* :class:`Symfony\\Bridge\\Doctrine\\Form\\DoctrineOrmTypeGuesser`
1414
provided by the Doctrine bridge.
1515

16+
Guessers are used only in the following cases:
17+
18+
* Using
19+
:method:`Symfony\\Component\\Form\\FormFactoryInterface::createForProperty`
20+
or
21+
:method:`Symfony\\Component\\Form\\FormFactoryInterface::createBuilderForProperty`;
22+
* Calling :method:`Symfony\\Component\\Form\\FormInterface::add` or
23+
:method:`Symfony\\Component\\Form\\FormBuilderInterface::create` or
24+
:method:`Symfony\\Component\\Form\\FormBuilderInterface::add` without an
25+
explicit type, in a context where the parent form has defined a data class.
26+
1627
Create a PHPDoc Type Guesser
1728
----------------------------
1829

@@ -70,7 +81,7 @@ The ``TypeGuess`` constructor requires three options:
7081

7182
* The type name (one of the :doc:`form types </reference/forms/types>`);
7283
* Additional options (for instance, when the type is ``entity``, you also
73-
want to set the ``class`` option). If no types are guessed, this should be
84+
want to set the ``class`` option). If no options are guessed, this should be
7485
set to an empty array;
7586
* The confidence that the guessed type is correct. This can be one of the
7687
constants of the :class:`Symfony\\Component\\Form\\Guess\\Guess` class:
@@ -153,11 +164,11 @@ set.
153164

154165
.. caution::
155166

156-
You should be very careful using the ``guessPattern()`` method. When the
157-
type is a float, you cannot use it to determine a min or max value of the
158-
float (e.g. you want a float to be greater than ``5``, ``4.512313`` is not valid
159-
but ``length(4.512314) > length(5)`` is, so the pattern will succeed). In
160-
this case, the value should be set to ``null`` with a ``MEDIUM_CONFIDENCE``.
167+
You should be very careful using the ``guessMaxLength()`` method. When the
168+
type is a float, you cannot determine a length (e.g. you want a float to be
169+
less than ``5``, ``5.512313`` is not valid but
170+
``length(5.512314) > length(5)`` is, so the pattern will succeed). In this
171+
case, the value should be set to ``null`` with a ``MEDIUM_CONFIDENCE``.
161172

162173
Registering a Type Guesser
163174
--------------------------

0 commit comments

Comments
 (0)