Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap form theme in Symfony 3.1

Tags:

symfony

I would like to know how to include a form theme designed for Bootstrap 3. This option was introduced in Symfony 2.6, but in Symfony 3.1 it was moved or deleted, becouse this solution does not work as it should: New in Symfony 2.6: Bootstrap form theme.

When I tried to set:

twig:
debug:            "%kernel.debug%"
strict_variables: "%kernel.debug%"
form:
    resources: ['bootstrap_3_layout.html.twig']

I got this message:

Fatal error: Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' with message 'Unrecognized option "form" under "twig"' in ...

I know about

{% form_theme form 'bootstrap_3_layout.html.twig' %}

and it works very well, but I want to set this theme permanently in a config file.

like image 957
ZaquPL Avatar asked Jun 24 '16 11:06

ZaquPL


1 Answers

I think the config key changed.

Try :

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

http://symfony.com/doc/current/cookbook/form/form_customization.html#twig

like image 175
Alsatian Avatar answered Oct 19 '22 02:10

Alsatian