{% if layer.parent == null %}
    {% set type = "root" %}
{% elseif layer.sublayer|length > 0 %}
    {% set type = "node" %}
{% else %}
    {% set type = "item" %}
{% endif %}

{% for form_layer in form_layers %}
    {% if form_layer.vars.value.id == layer.id %}
        <tr id="{{ type }}{{ layer.id }}" class="{{ type }} level{{ level }}" data-id="{{ form_layer.vars.value.id }}"{% if layer.parent != null %} data-parent="{{layer.parent.id}}"{% endif %} data-type="{{ type }}"
            data-href="{{path("mapbender_manager_repository_instancelayerweight", {"slug": slug, "instanceId": instance.id, "instLayerId": form_layer.vars.value.id})}}">
            <td class="level{{ level }} itemType {% if type == 'node' or  type == 'root' %}iconFolderActive{% else %}iconLinkButton{% endif %} hover-highlight-effect"></td>
            <td class="titleColumn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.layerstitle"|trans }}">{{ form_widget(form_layer.title) }}</td>

            <td class="minScaleColumn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.minscale"|trans }}">{{ form_widget(form_layer.minScale, {'attr': {'placeholder': form_layer.vars.value.getInheritedMinScale()}}) }}</td>
            <td class="maxScaleColumn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.maxsclase"|trans }}">{{ form_widget(form_layer.maxScale, {'attr': {'placeholder': form_layer.vars.value.getInheritedMaxScale()}}) }}</td>

            <td class="checkboxColumn" data-check-identifier="checkActive" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.active"|trans }}">{{ form_widget(form_layer.active) }}</td>
            <td class="checkboxColumn odd" data-check-identifier="checkSelectAllow" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.allowselecttoc"|trans }}">{{ form_widget(form_layer.allowselected) }}</td>
            <td class="checkboxColumn odd" data-check-identifier="checkSelectOn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.selectedtoc"|trans }}">{{ form_widget(form_layer.selected) }}</td>
            <td class="checkboxColumn" data-check-identifier="checkInfoAllow" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.allowinfotoc"|trans }}">{{ form_widget(form_layer.allowinfo) }}</td>
            <td class="checkboxColumn" data-check-identifier="checkInfoOn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.infotoc"|trans }}">{{ form_widget(form_layer.info) }}</td>
            <td class="checkboxColumn odd" data-check-identifier="checkToggleAllow" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.allowtoggletoc"|trans }}">{{ form_widget(form_layer.allowtoggle) }}</td>
            <td class="checkboxColumn odd" data-check-identifier="checkToggleOn" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.toggletoc"|trans }}">{{ form_widget(form_layer.toggle) }}</td>
            <td class="checkboxColumn" data-check-identifier="checkRecorderAllow" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.allowreordertoc"|trans }}">{{ form_widget(form_layer.allowreorder) }}</td>
            <td class="moreColumn">
              <span class="iconMore" title="{{'mb.wms.wmsloader.repo.instancelayerform.label.moreinfo'|trans}}">
                <div class="infoMsgBox hide">
                  <span class="hide layer-priority">{{ form_widget(form_layer.priority) }}</span>
                  <span class="labelText">{{ "mb.wms.wmsloader.repo.instancelayerform.label.id.title"|trans }}</span> <span class="smallText" title="{{ "mb.wms.wmsloader.repo.instancelayerform.label.id.description"|trans }}">{{layer.sourceInstance.source.id}}-{{layer.sourceItem.id}}/{{layer.sourceInstance.id}}-{{layer.id}}</span><br>
                  <span class="labelText">{{ "mb.wms.wmsloader.repo.instancelayerform.label.layersname"|trans }}</span><span class="smallText">{{ form_layer.vars.data.sourceItem.name}}</span>
                  <br>
                  <span class="labelText">{{"mb.wms.wmsloader.repo.instancelayerform.label.style"|trans}}</span>{{ form_widget(form_layer.style) }}
                </div>
              </span>
            </td>

            {% if layer.sublayer|length > 0 %}
                {% for sublayer in layer.sublayer %}
                    {% include "MapbenderWmsBundle:Repository:instance-layer-form.html.twig"  with {'form_layers': form_layers, 'layer': sublayer, 'level': level + 1 }%}
                {% endfor %}
            {% endif %}
        </tr>
    {% endif %}
{% endfor %}
