Skip to content

Commit 9b373f0

Browse files
committed
[book][forms] Changing the block names to use a single underscore (upstream changes)
1 parent b4b8754 commit 9b373f0

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

book/forms.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -819,15 +819,15 @@ do this, create a new template file that will store the new markup:
819819

820820
{# src/Acme/StoreBundle/Resources/views/Form/fields.html.twig #}
821821

822-
{% block field__row %}
822+
{% block field_row %}
823823
{% spaceless %}
824824
<div class="form_row">
825825
{{ form_label(form, label) }}
826826
{{ form_errors(form) }}
827827
{{ form_widget(form, _context) }}
828828
</div>
829829
{% endspaceless %}
830-
{% endblock field__row %}
830+
{% endblock field_row %}
831831

832832
.. code-block:: html+php
833833

@@ -838,8 +838,8 @@ do this, create a new template file that will store the new markup:
838838
<?php echo $view['form']->widget($form, $parameters) ?>
839839
</div>
840840

841-
The ``field__row`` block is the name of the block used when rendering most
842-
fields via the ``form_row`` function. To use the ``field__row`` defined
841+
The ``field_row`` block is the name of the block used when rendering most
842+
fields via the ``form_row`` function. To use the ``field_row`` defined
843843
in this template, add the following to the top of the template that renders
844844
the form:
845845

@@ -854,7 +854,7 @@ the form:
854854

855855
The ``form_theme`` tag "imports" a template and uses all of its form-related
856856
blocks when rendering the form. When ``form_row`` is called, it uses the
857-
``field__row`` block for the ``fields.html.twig`` template.
857+
``field_row`` block for the ``fields.html.twig`` template.
858858

859859
To customize any portion of a form, you just need to override the appropriate
860860
block. Knowing exactly which block to override is the subject of the next
@@ -869,32 +869,32 @@ block needed is defined in the `div_layout.html.twig`_ file that lives inside
869869
the core ``TwigBundle``. Inside this file, you can see every block needed
870870
to render a form and every default field type.
871871

872-
Each block follows the same basic pattern and his broken up into two pieces,
873-
separated by two underscore characters (``__``). A few examples are:
872+
Each block follows the same basic pattern and is broken up into two pieces,
873+
separated by a single underscore character (``_``). A few examples are:
874874

875-
* ``field__row`` - used by ``form_row`` to render most fields;
876-
* ``textarea__widget`` - used by ``form_widget`` to render a ``textarea`` field type;
875+
* ``field_row`` - used by ``form_row`` to render most fields;
876+
* ``textarea_widget`` - used by ``form_widget`` to render a ``textarea`` field type;
877877
* ``field_errors`` - used by ``form_errors`` to render errors for a field;
878878

879-
Each block follows the same basic pattern: ``type__part``. The ``type`` portion
879+
Each block follows the same basic pattern: ``type_part``. The ``type`` portion
880880
corresponds to the field type being rendered (e.g. ``textarea`` or ``checkbox``)
881881
whereas the ``part`` portion corresponds to *what* is being rendered (e.g.
882882
``label``, ``widget``). By default, there are exactly 7 possible parts of
883883
a form that can be rendered:
884884

885885
============ ========================= ============================
886-
``label`` (e.g. ``field__label``) renders the field's label
887-
``widget`` (e.g. ``field__widget``) renders the field's HTML representation
888-
``errors`` (e.g. ``field__errors``) renders the field's errors
889-
``row`` (e.g. ``field__row``) renders the field's entire row (label+widget+errors)
890-
``rows`` (e.g. ``field__rows``) renders the child rows of a form
891-
``rest`` (e.g. ``field__rest``) renders the unrendered fields of a form
892-
``enctype`` (e.g. ``field__enctype``) renders the ``enctype`` attribute of a form
886+
``label`` (e.g. ``field_label``) renders the field's label
887+
``widget`` (e.g. ``field_widget``) renders the field's HTML representation
888+
``errors`` (e.g. ``field_errors``) renders the field's errors
889+
``row`` (e.g. ``field_row``) renders the field's entire row (label+widget+errors)
890+
``rows`` (e.g. ``field_rows``) renders the child rows of a form
891+
``rest`` (e.g. ``field_rest``) renders the unrendered fields of a form
892+
``enctype`` (e.g. ``field_enctype``) renders the ``enctype`` attribute of a form
893893
============ ========================= ============================
894894

895895
By knowing the field type (e.g. ``textarea``) and which part you want to
896896
customize (e.g. ``widget``), you can construct the block name that needs
897-
to be overridden (e.g. ``textarea__widget``). The best way to customize the
897+
to be overridden (e.g. ``textarea_widget``). The best way to customize the
898898
block is to copy it to a new template, customize it, and then use the ``form_theme``
899899
tag as was shown in the earlier example.
900900

@@ -970,9 +970,9 @@ to define form output.
970970

971971
{% form_theme form _self %}
972972

973-
{% block field__row %}
973+
{% block field_row %}
974974
{# custom field row output #}
975-
{% endblock field__row %}
975+
{% endblock field_row %}
976976

977977
{{ form_row(form.name) }}
978978

0 commit comments

Comments
 (0)