0

I looked everywhere but I can't find a documentation on how to apply bootstrap styles to Symfony, or twig to be precise.

Many answers are outdated as they are mostly about Symfony 2.x with bootstrap3.

For reference, I am trying to add a style to

{{ form_start(form))}}
{{ form_widget(form) }}
{{ form_end(form) }}
6

1 Answer 1

3

Since Symfony 2.6, Bootstrap is included in Symfony without the need for a specific bundle, as announced in this news, and explained in the doc here.

There are 2 layouts available, the normal layout and the horizontal one.

To apply it everywhere:

# app/config/config.yml
twig:
    form_themes:
        - 'bootstrap_3_layout.html.twig'
        # - 'bootstrap_3_horizontal_layout.html.twig'

Or only for specific forms, add this at the top of the corresponding Twig files:

{% form_theme form 'bootstrap_3_layout.html.twig' %}
{# {% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %} #}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.