Collapse bootstrap tags

I am trying to collapse labels using Bootstrap in the form of a Symfony project, but does not seem to work as follows:

File.html.twig

<div class="form-group">
    {{
        form_label(form.Text,
                   'Text:',
                   {'label_attr': {'class': 'col-xs-2 control-label'}}
        )
    }}

    <div class="col-xs-2" style="width: 440px">
        <button type="button" class="btn btn-info" data-dismiss="modal"
                data-toggle="collapse" data-target="#text">TEXT</button>
        {{
            form_widget(form.Text,
                        {'attr': {'id': 'text',
                                  'class': 'collapse', 
                                  'placeholder': 'text..', 
                                  'style' : 'height: 200px'}}
            )
        }}
        {{ form_errors(form.Text) }}
    </div>

Is there any other way to do this in Bootstrap? Or in any other way, but simply?

+4
source share
1 answer

Assuming bootstrap usually works, there is one problem displaying your form:

Symfony automatically sets the id attribute. This way, when 'id': 'text'you do not rewrite symfonys id, you just add another id attribute, for example.

 <input type="text" id="pec_bundle_travelCostsBundle_test_Text" ... id="text" class="collapse" placeholder="text.." style="height: 200px" />

bootstrap #text. 'id': 'text' data-target symfony. :

<button type="button" class="btn btn-info" data-dismiss="modal"
        data-toggle="collapse" data-target="#pec_bundle_travelCostsBundle_test_Text">TEXT</button>
{{
    form_widget(form.Text,
                {'attr': {
                        'class': 'collapse', 
                        'placeholder': 'text..', 
                        'style' : 'height: 200px'}}
    )
}}
{{ form_errors(form.Text) }}

id, - .

0

All Articles