Search code examples
phpsymfonytwitter-bootstrap-3bundles

Cant assign CSS class in FormType Symfony2


I installed bootstrap via bundle in Symfony2. But now I getting the some strange situation, when I append the class selcetor to form field of date type. In output I getting it with bootstrap-date class, and I cant change it. So where is the my problem? Thanks! Here is the FormType code:

->add('startDate', 'date', [
            'label' => 'Start date',
            'attr' => [
                'class' => 'advanced_search_form',
            ],
 ])

Here is HTML:


Solution

  • You can do this from the twig template:

    {{ form_widget(form.startDate, { 'attr': {'class': 'advanced_search_form'} }) }}