Skip to content

Commit 3b3cd6f

Browse files
committed
Added references
1 parent f36fdb7 commit 3b3cd6f

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

components/form/type_guesser.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,26 @@ set.
144144
float (e.g. you want a float to be greater than ``5``, ``4.512313`` is not valid
145145
but ``length(4.512314) > length(5)`` is, so the pattern will success). In
146146
this case, the value should be set to ``null`` with a ``MEDIUM_CONFIDENCE``.
147+
148+
Registering a Type Guesser
149+
--------------------------
150+
151+
The last thing you need to do is registering your custom type guesser by using
152+
:method:`Symfony\\Component\\Form\\FormFactoryBuilder::addTypeGuesser` or
153+
:method:`Symfony\\Component\\Form\\FormFactoryBuilder::addTypeGuessers`::
154+
155+
use Symfony\Component\Form\Forms;
156+
use Acme\Form\PHPDocTypeGuesser;
157+
158+
$formFactory = Forms::createFormFactoryBuilder()
159+
// ...
160+
->addTypeGuesser(new PHPDocTypeGuesser())
161+
->getFormFactory();
162+
163+
// ...
164+
165+
.. note::
166+
167+
When you use the full stack framework, you need to register your type
168+
guesser and tag it with ``form.type_guesser``. For more information see
169+
:ref:`the tag reference <reference-dic-type_guesser>`.

reference/dic_tags.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,22 @@ The ``alias`` key of the tag is the type of field that this extension should
332332
be applied to. For example, to apply the extension to any form/field, use the
333333
"form" value.
334334
335+
.. _reference-dic-type_guesser:
336+
335337
form.type_guesser
336338
-----------------
337339
338340
**Purpose**: Add your own logic for "form type guessing"
339341
340342
This tag allows you to add your own logic to the :ref:`Form Guessing <book-forms-field-guessing>`
341343
process. By default, form guessing is done by "guessers" based on the validation
342-
metadata and Doctrine metadata (if you're using Doctrine).
344+
metadata and Doctrine metadata (if you're using Doctrine) or Propel metadata
345+
(if you're using Propel).
343346
344-
To add your own form type guesser, create a class that implements the
345-
:class:`Symfony\\Component\\Form\\FormTypeGuesserInterface` interface. Next,
346-
tag its service definition with ``form.type_guesser`` (it has no options).
347+
.. seelalso::
347348
348-
To see an example of how this class might look, see the ``ValidatorTypeGuesser``
349-
class in the Form component.
349+
For information on how to create your own type guesser, see
350+
:doc:`/components/form/type_guesser`.
350351
351352
kernel.cache_clearer
352353
--------------------

0 commit comments

Comments
 (0)