@@ -18,7 +18,7 @@ In order to create the custom field type, first we have to create the class
18
18
representing the field. In our situation the class holding the field type
19
19
will be called `GenderType ` and the file will be stored in the default location
20
20
for form fields, which is ``<BundleName>\Form\Type ``. Make sure the field extends
21
- `` AbstractType ` `::
21
+ :class: ` Symfony \\ Component \\ Form \\ AbstractType `::
22
22
23
23
# src/Acme/DemoBundle/Form/Type/GenderType.php
24
24
namespace Acme\DemoBundle\Form\Type;
@@ -65,7 +65,7 @@ important:
65
65
you use to setup *your * forms, and it works the same here.
66
66
67
67
* ``buildView() `` - This method is used to set any extra variables you'll
68
- need when rendering your field in a template. For example, in `` ChoiceType `` ,
68
+ need when rendering your field in a template. For example, in `ChoiceType `_ ,
69
69
a ``multiple `` variable is set and used in the template to set (or not
70
70
set) the ``multiple `` attribute on the ``select `` field. See `Creating a Template for the Field `_
71
71
for more details.
@@ -82,9 +82,9 @@ important:
82
82
Also, if you need to modify the "view" of any of your child types from
83
83
your parent type, use the ``buildViewBottomUp() `` method.
84
84
85
- The ``getName() `` method returns an identifier which is used to prevent conflicts
86
- with other types. Other than needing to be unique, this method isn't very
87
- important .
85
+ The ``getName() `` method returns an identifier which should be unique in
86
+ your application. This is used in various places, such as when customizing
87
+ how your form type will be rendered .
88
88
89
89
The goal of our field was to extend the choice type to enable selection of
90
90
a gender. This is achieved by fixing the ``choices `` to a list of possible
@@ -107,7 +107,6 @@ we want to always render it in a ``ul`` element. In your form theme template
107
107
.. code-block :: html+jinja
108
108
109
109
{# src/Acme/DemoBundle/Resources/Form/fields.html.twig #}
110
- {% use 'form_div_layout.html.twig' with choice_widget %}
111
110
112
111
{% block gender_widget %}
113
112
{% spaceless %}
@@ -227,9 +226,9 @@ the ``genders`` parameter value as the first argument to its to-be-created
227
226
Make sure the services file is being imported. See :ref: `service-container-imports-directive `
228
227
for details.
229
228
230
- Be sure that the ``alias `` tag corresponds with the value returned by the
231
- ``getName `` method defined earlier. We'll see the importance of this in a
232
- moment when we use the custom field type. But first, add a ``__construct ``
229
+ Be sure that the ``alias `` attribute of the tag corresponds with the value
230
+ returned by the ``getName `` method defined earlier. We'll see the importance
231
+ of this in a moment when we use the custom field type. But first, add a ``__construct ``
233
232
argument to ``GenderType ``, which receives the gender configuration::
234
233
235
234
# src/Acme/DemoBundle/Form/Type/GenderType.php
0 commit comments