Skip to content

Commit 45b56c4

Browse files
committed
[Form] Improve form type guessers section
1 parent dba6794 commit 45b56c4

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:
@@ -162,11 +173,11 @@ set.
162173

163174
.. caution::
164175

165-
You should be very careful using the ``guessPattern()`` method. When the
166-
type is a float, you cannot use it to determine a min or max value of the
167-
float (e.g. you want a float to be greater than ``5``, ``4.512313`` is not valid
168-
but ``length(4.512314) > length(5)`` is, so the pattern will succeed). In
169-
this case, the value should be set to ``null`` with a ``MEDIUM_CONFIDENCE``.
176+
You should be very careful using the ``guessMaxLength()`` method. When the
177+
type is a float, you cannot determine a length (e.g. you want a float to be
178+
less than ``5``, ``5.512313`` is not valid but
179+
``length(5.512314) > length(5)`` is, so the pattern will succeed). In this
180+
case, the value should be set to ``null`` with a ``MEDIUM_CONFIDENCE``.
170181

171182
Registering a Type Guesser
172183
--------------------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy