Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Following Manual Instructions for Bootstrap 3 forms getting yml config error

I'm following directions directly from the manual. I've got this configuration setting in my config.yml

twig:
    form:
        resources: ['bootstrap_3_layout.html.twig']

haven't got this far but in my base.html.twig i have...

    <link rel="stylesheet" 
          href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
          integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" 
          crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" 
          href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" 
          integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" 
          crossorigin="anonymous">
    {% block stylesheets %}{% endblock %}

And of course the appropriate call for jquery and boostrap.js at bottom of base.html.twig

In any of my templates I have....

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


{% block body %} //etc. etc.

I get the error:

InvalidConfigurationException in ArrayNode.php line 317:
Unrecognized option "form" under "twig"

did they change the yml configuration settings and not update it in the manual?

like image 617
Rick Mason Avatar asked Jan 28 '16 22:01

Rick Mason


2 Answers

In newer Symfony versions, you must use form_themes instead of form.resources:

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

And, you don't need to add this to your templates:

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

You can safely remove that tag and forms will still use the Bootstrap form theme (because you configured it globally in config.yml file).

This is the official documentation about this: http://symfony.com/doc/2.6/cookbook/form/form_customization.html#making-application-wide-customizations

like image 187
Javier Eguiluz Avatar answered Sep 21 '22 13:09

Javier Eguiluz


Probably the doc is mysaligned for the related framework version.

Try this:

config.yml

twig:
    form_themes:
        # Bootstrap:
        - bootstrap_3_layout.html.twig

take a look at the TWIG bundle documentation here to see a full doc of the related bundle configuration.

Hope this help

like image 32
Matteo Avatar answered Sep 22 '22 13:09

Matteo