Bootstrap 3 does not work in Symfony3

I just started to learn Symfony3 and I am trying to use the theme of my form using bootstrap3. According to the documentation , bootstrap_3_layout.html.twig is built-in and can be activated globally by changing Twig settings in config.yml :

 # Twig Configuration twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%" form_themes: - "bootstrap_3_layout.html.twig" 

When I reload the page, the page loads without CSS, the twig file and page source look like this:

 {# app/Resources/views/experiment/new.html.twig #} {{ form_start(form) }} {{ form_widget(form) }} {{ form_end(form) }} <form name="form" method="post"> <div id="form"><div class="form-group"><label class="control-label required" for="form_title">Title</label><input type="text" id="form_title" name="form[title]" required="required" class="form-control" /></div><div class="form-group"><button type="submit" id="form_save" name="form[save]" class="btn-default btn">Create Task</button></div><input type="hidden" id="form__token" name="form[_token]" class="form-control" value="O7tN2AUjyLByEz2tkNf675jqixxjev0p4ivzs5Bn4VA" /></div> </form> 

Which shows that the bootstrap3 classes were entered correctly. The site itself is as follows:

enter image description here

What steps did I skip to get CSS to work correctly?

+5
source share
2 answers

You still need to add bootstrap, CSS, and JS files to your application and templates. The form theme only ensures that the markup is well-formed in accordance with the initial loading.

+4
source

As an alternative way, you can include the package

https://github.com/phiamo/MopaBootstrapBundle

In your project and get the Bootstrap files (sass / less) into your project.

Installation documentation is also available on this page. I use self-recording integration that uses similar methods.

The advantage is that you can include custom sass in your project and compile it into a single css file, which you include in the template header.

+1
source

Source: https://habr.com/ru/post/1237726/


All Articles