Skip to content

Commit c4368fd

Browse files
committed
Proofing changes to form_customization chapter
1 parent 4bb4475 commit c4368fd

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

cookbook/form/form_customization.rst

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
How to customize Form Rendering
22
===============================
33

4-
Symfony gives you a wide variety of ways to customize the form rendering. In this
5-
guide, you'll learn how to customize every possible part of your form with as
6-
little effort as possible whether you use Twig or PHP as the templating engine.
4+
Symfony gives you a wide variety of ways to customize how a form is rendered.
5+
In this guide, you'll learn how to customize every possible part of your
6+
form with as little effort as possible whether you use Twig or PHP as your
7+
templating engine.
78

89
Form Rendering Basics
910
---------------------
1011

1112
Recall that the label, error and HTML widget of a form field can easily
12-
be rendered by using the ``form_row`` Twig function or the ``row`` helper
13+
be rendered by using the ``form_row`` Twig function or the ``row`` PHP helper
1314
method:
1415

1516
.. code-block:: jinja
@@ -70,18 +71,23 @@ rendering in general, see :ref:`form-rendering-template`.
7071
What are Form Themes?
7172
---------------------
7273

73-
Symfony uses fragments which are markup templates for each and every part of a
74-
form - field labels, errors, ``input`` text fields, ``select`` tags, etc - when
75-
rendering a form.
74+
Symfony uses form fragments - a small piece of a template that renders just
75+
one part of a form - to render every part of a form - - field labels, errors,
76+
``input`` text fields, ``select`` tags, etc
7677

7778
The fragments are defined as blocks in Twig and as template files in PHP.
7879

79-
A theme is no more than a set of fragments to use when rendering a form. Symfony
80-
comes with a default theme (`form_div_layout.html.twig`_ in Twig and ``FrameworkBundle:Form``
81-
in PHP).
80+
A *theme* is nothing more than a set of fragments that you want to use when
81+
rendering a form. In other words, if you want to customize one portion of
82+
how a form is rendered, you'll import a *theme* which contains a customization
83+
of the appropriate form fragments.
8284

83-
In the next section you will learn how to customize a theme by overriding some or
84-
all of the fragments in a base theme.
85+
Symfony comes with a default theme (`form_div_layout.html.twig`_ in Twig and
86+
``FrameworkBundle:Form`` in PHP) that defines each and every fragment needed
87+
to render every part of a form.
88+
89+
In the next section you will learn how to customize a theme by overriding
90+
some or all of its fragments.
8591

8692
For example, when the widget of a ``integer`` type field is rendered, an ``input``
8793
``number`` field is generated
@@ -146,7 +152,7 @@ As you can see, this fragment itself renders another fragment - ``field_widget``
146152

147153
The point is, the fragments dictate the HTML output of each part of a form. To
148154
customize the form output, you just need to identify and override the correct
149-
fragment. A set of these form fragment customizations is known as a from "theme".
155+
fragment. A set of these form fragment customizations is known as a form "theme".
150156
When rendering a form, you can choose which form theme(s) you want to apply.
151157

152158
In Twig a theme is a single template file and the fragments are the blocks defined
@@ -281,7 +287,7 @@ block from the new template and the ``input`` tag will be wrapped in the
281287
Form Theming in PHP
282288
-------------------
283289

284-
When using PHP as a templating engine the only method to customize a fragment
290+
When using PHP as a templating engine, the only method to customize a fragment
285291
is to create a new template file - this is similar to the second method used by
286292
Twig.
287293

@@ -378,7 +384,7 @@ Making Application-wide Customizations
378384
--------------------------------------
379385

380386
If you'd like a certain form customization to be global to your application,
381-
you can accomplish this by making the form customizations to an external
387+
you can accomplish this by making the form customizations in an external
382388
template and then importing it inside your application configuration:
383389

384390
Twig
@@ -397,7 +403,6 @@ form is rendered.
397403
twig:
398404
form:
399405
resources:
400-
- 'form_div_layout.html.twig'
401406
- 'AcmeDemoBundle:Form:fields.html.twig'
402407
# ...
403408
@@ -407,7 +412,6 @@ form is rendered.
407412
408413
<twig:config ...>
409414
<twig:form>
410-
<resource>form_div_layout.html.twig</resource>
411415
<resource>AcmeDemoBundle:Form:fields.html.twig</resource>
412416
</twig:form>
413417
<!-- ... -->
@@ -419,7 +423,6 @@ form is rendered.
419423
420424
$container->loadFromExtension('twig', array(
421425
'form' => array('resources' => array(
422-
'form_div_layout.html.twig',
423426
'AcmeDemoBundle:Form:fields.html.twig',
424427
))
425428
// ...
@@ -489,7 +492,6 @@ form is rendered.
489492
templating:
490493
form:
491494
resources:
492-
- 'FrameworkBundle:Form'
493495
- 'AcmeDemoBundle:Form'
494496
# ...
495497
@@ -501,7 +503,6 @@ form is rendered.
501503
<framework:config ...>
502504
<framework:templating>
503505
<framework:form>
504-
<resource>FrameworkBundle:Form</resource>
505506
<resource>AcmeDemoBundle:Form</resource>
506507
</framework:form>
507508
</framework:templating>
@@ -517,7 +518,6 @@ form is rendered.
517518
$container->loadFromExtension('framework', array(
518519
'templating' => array('form' =>
519520
array('resources' => array(
520-
'FrameworkBundle:Form',
521521
'AcmeDemoBundle:Form',
522522
)))
523523
// ...
@@ -614,6 +614,7 @@ Here, the ``_product_name_widget`` fragment defines the template to use for the
614614
field whose *id* is ``product_name`` (and name is ``product[name]``).
615615

616616
.. tip::
617+
617618
The ``product`` portion of the field is the form name, which may be set
618619
manually or generated automatically based on your form type name (e.g.
619620
``ProductType`` equates to ``product``). If you're not sure what your

0 commit comments

Comments
 (0)