lundi 26 octobre 2015

How to control marked checkbox order in twig

So I'm facing this weird behavior when listing a series of checkboxes with twig

see the new page, it displays everything right, and saying that i'm saving this laboratory

img1 enter image description here

ok, I saved the laboratory, now went to the edit page

img2 enter image description here

the marked checkboxes displays at first, ruining the alphabetic order that was at the new page.

I need that the edit page become exactly like the new page, but I don't know how to organize these checkboxes on twig.

block that renders the checkboxes:

{% block _appbundle_laboratory_laboratoryExams_row %}
    <div class="form-group">
        {{ form_label(form) }}
        <div class="col-md-10 col-md-offset-2">
            <div class="app-checkbox-collection">
                <p>{{ 'laboratory.field_laboratory' | trans }}</p>
                {%  dump(form) %}
                {% for child in form %}
                    {% if child.exam.vars.data.type == constant('AppBundle\\Entity\\ExamLaboratory::TYPE')%}
                        {{ form_widget(child.permission, {
                            'attr' : {
                                'class' : 'exam-checkbox'
                            },
                            'label' : child.exam.vars.data.name
                        }) }}
                    {% endif %}
                {% endfor %}
                <p>{{ 'laboratory.field_image' | trans }}</p>
                {% for child in form %}
                    {% if child.exam.vars.data.type == constant('AppBundle\\Entity\\ExamImage::TYPE')%}
                        {{ form_widget(child.permission, {
                            'attr' : {
                                'class' : 'exam-checkbox'
                            },
                            'label' : child.exam.vars.data.name
                        }) }}
                    {% endif %}
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}

I don't ask at portuguese stackoverflow because no one answers symfony questions there, few users probably




Aucun commentaire:

Enregistrer un commentaire