Skip to content

Commit

Permalink
use code-block twig instead of html+twig
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Apr 8, 2019
1 parent 1b8aacb commit 7c1cf8a
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ One of the simplest ways - which is especially useful during development -
is to render the form tags and use the ``form_widget()`` function to render
all of the fields:

.. code-block:: html+twig
.. code-block:: twig
{{ form_start(form, {'attr': {'class': 'my-form-class'} }) }}
{{ form_widget(form) }}
Expand Down
2 changes: 1 addition & 1 deletion form/action_method.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ options:
Finally, you can override the action and method in the template by passing them
to the ``form()`` or the ``form_start()`` helper functions:

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/default/new.html.twig #}
{{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }}
Expand Down
2 changes: 1 addition & 1 deletion form/bootstrap4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Bootstrap 4 has a feature called "`custom forms`_". You can enable that on your
Symfony Form ``RadioType`` and ``CheckboxType`` by adding a class called ``radio-custom``
and ``checkbox-custom`` respectively.

.. code-block:: html+twig
.. code-block:: twig
{{ form_row(form.myRadio, {label_attr: {class: 'radio-custom'} }) }}
{{ form_row(form.myCheckbox, {label_attr: {class: 'checkbox-custom'} }) }}
Expand Down
2 changes: 1 addition & 1 deletion form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ new "tag" forms. To render it, make the following change to your template:
on it. You could even choose to render only one of its fields (e.g. the
``name`` field):

.. code-block:: html+twig
.. code-block:: twig
{{ form_widget(form.tags.vars.prototype.name)|e }}
Expand Down
16 changes: 8 additions & 8 deletions form/form_customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ some or all of its fragments.
For example, when the widget of an ``integer`` type field is rendered, an ``input``
``number`` field is generated

.. code-block:: html+twig
.. code-block:: twig
{{ form_widget(form.age) }}
Expand Down Expand Up @@ -272,7 +272,7 @@ Now that you've created the customized form block, you need to tell Symfony
to use it. Inside the template where you're actually rendering your form,
tell Symfony to use the template via the ``form_theme`` tag:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form 'form/fields.html.twig' %}
Expand All @@ -288,7 +288,7 @@ Multiple Templates
A form can also be customized by applying several templates. To do this, pass the
name of all the templates as an array using the ``with`` keyword:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] %}
Expand All @@ -307,7 +307,7 @@ of Symfony applications (and so you can't control what themes are defined global

You can do this by including the ``only`` keyword after the list of form themes:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] only %}
Expand All @@ -321,7 +321,7 @@ You can do this by including the ``only`` keyword after the list of form themes:
yourself, or extend one of the built-in form themes with Twig's ``use``
keyword instead of ``extends`` to re-use the original theme contents.

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/common.html.twig #}
{% use "form_div_layout.html.twig" %}
Expand All @@ -333,14 +333,14 @@ Child Forms

You can also apply a form theme to a specific child of your form:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form.a_child_form 'form/fields.html.twig' %}
This is useful when you want to have a custom theme for a nested form that's
different than the one of your main form. Just specify both your themes:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form 'form/fields.html.twig' %}
Expand Down Expand Up @@ -503,7 +503,7 @@ resource to use such a layout:
If you only want to make the change in one template, add the following line to
your template file rather than adding the template as a resource:

.. code-block:: html+twig
.. code-block:: twig
{% form_theme form 'form_table_layout.html.twig' %}
Expand Down
4 changes: 2 additions & 2 deletions form/form_themes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The ``form_row`` form fragment is used when rendering most fields via the
fragment defined above, add the following to the top of the template that
renders the form:

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/default/new.html.twig #}
{% form_theme form 'form/fields.html.twig' %}
Expand Down Expand Up @@ -225,7 +225,7 @@ to define form output.
In Twig, you can also customize a form block right inside the template
where that customization is needed:

.. code-block:: html+twig
.. code-block:: twig
{% extends 'base.html.twig' %}
Expand Down
10 changes: 5 additions & 5 deletions form/rendering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ How to Control the Rendering of a Form
So far, you've seen how an entire form can be rendered with just one line
of code. Of course, you'll usually need much more flexibility when rendering:

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/default/new.html.twig #}
{{ form_start(form) }}
Expand Down Expand Up @@ -79,7 +79,7 @@ used the ``form_row()`` helper:
If the auto-generated label for a field isn't quite right, you can explicitly
specify it:

.. code-block:: html+twig
.. code-block:: twig
{{ form_label(form.task, 'Task Description') }}
Expand All @@ -89,22 +89,22 @@ option is ``attr``, which allows you to modify attributes on the form element.
The following would add the ``task_field`` class to the rendered input text
field:

.. code-block:: html+twig
.. code-block:: twig
{{ form_widget(form.task, {'attr': {'class': 'task_field'}}) }}
If you need to render form fields "by hand" then you can access individual
values for fields such as the ``id``, ``name`` and ``label``. For example
to get the ``id``:

.. code-block:: html+twig
.. code-block:: twig
{{ form.task.vars.id }}
To get the value used for the form field's name attribute you need to use
the ``full_name`` value:

.. code-block:: html+twig
.. code-block:: twig
{{ form.task.vars.full_name }}
Expand Down
4 changes: 2 additions & 2 deletions forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ done by passing a special form "view" object to your template (notice the
``$form->createView()`` in the controller above) and using a set of form
helper functions:

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/default/new.html.twig #}
{{ form_start(form) }}
Expand Down Expand Up @@ -409,7 +409,7 @@ Validation is a very powerful feature of Symfony and has its own
but are being prevented by your browser from, for example, submitting
blank fields.

.. code-block:: html+twig
.. code-block:: twig
{# app/Resources/views/default/new.html.twig #}
{{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
Expand Down
2 changes: 1 addition & 1 deletion quick_tour/the_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ forget to add the new ``use`` statement that imports this ``Request`` class)::
In a template, you can also access the ``Request`` object via the special
``app.request`` variable automatically provided by Symfony:

.. code-block:: html+twig
.. code-block:: twig
{{ app.request.query.get('page') }}
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/options/button_label.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ be directly set inside the template:

.. configuration-block::

.. code-block:: html+twig
.. code-block:: twig

{{ form_widget(form.save, { 'label': 'Click me' }) }}

Expand Down
2 changes: 1 addition & 1 deletion templating/escaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ is that dynamic content could break the HTML of the resulting page or allow
a malicious user to perform a `Cross Site Scripting`_ (XSS) attack. Consider
this classic example:

.. code-block:: html+twig
.. code-block:: twig
Hello {{ name }}
Expand Down
2 changes: 1 addition & 1 deletion templating/render_without_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ within a template is typically to prepare some data in a custom controller,
this is probably only useful if you'd like to cache this page partial (see
:ref:`templating-no-controller-caching`).

.. code-block:: html+twig
.. code-block:: twig
{{ render(url('acme_privacy')) }}
Expand Down

0 comments on commit 7c1cf8a

Please sign in to comment.