{% 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 }}">
            {% set _icon = (layer.sublayer | length) ? 'fa fas fa-folder-open' : 'fa fas fa-caret-right' %}
            <td class="level{{ level }} itemType"><span class="itemType {{ _icon }}"></span></td>
            <td class="titleColumn" title="{{ form_layer.title.vars.label | trans }}">{{ form_widget(form_layer.title) }}</td>

            <td class="minScaleColumn" title="{{ form_layer.minScale.vars.label | trans }}">{{ form_widget(form_layer.minScale) }}</td>
            <td class="maxScaleColumn" title="{{ form_layer.maxScale.vars.label | trans }}">{{ form_widget(form_layer.maxScale) }}</td>
            {{ form_row(form_layer.active) }}
            {{ form_row(form_layer.allowselected) }}
            {{ form_row(form_layer.selected) }}
            {{ form_row(form_layer.allowinfo) }}
            {{ form_row(form_layer.info) }}
            {{ form_row(form_layer.allowtoggle) }}
            {{ form_row(form_layer.toggle) }}
            <td class="moreColumn">
            <div class="static-popover-wrap">
              <div class="infoMsgBox popover left hidden">
                  <div class="arrow"></div>
                  <div class="popover-content">
                    <span class="hidden layer-priority">{{ form_widget(form_layer.priority) }}</span>
                    <div>
                      <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>
                    </div>
                    <div>
                      <span class="labelText">{{ "mb.wms.wmsloader.repo.instancelayerform.label.layersname"|trans }}</span><span class="smallText">{{ form_layer.vars.data.sourceItem.name}}</span>
                    </div>
                    {{ form_row(form_layer.style) }}
                  </div>
              </div>
              <span class="-fn-toggle-layer-detail" title="{{'mb.wms.wmsloader.repo.instancelayerform.label.moreinfo'|trans}}"><i class="fa fas fa-ellipsis-h"></i></span>
            </div>
            </td>

        </tr>
        {% 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 %}
    {% endif %}
{% endfor %}
