{% extends "_layouts/cp" %}
{% set title = globalSet.name|t('site') %}
{% set fullPageForm = true %}
{% set retainScrollOnSaveShortcut = true %}

{% if craft.app.getIsMultiSite() %}
    {% set siteMenuItems = siteMenuItems(null, requestedSite) %}
    {% set crumbs = [{
        id: 'site-crumb',
        icon: 'world',
        label: requestedSite.name|t('site'),
        menu: {
            items: siteMenuItems,
            label: 'Select site'|t('app')
        },
    }] %}
{% endif %}

{% hook "cp.globals.edit" %}


{% block sidebar %}
    <nav>
        <ul>
            {% for theGlobalSet in editableGlobalSets %}
                <li><a{% if theGlobalSet.handle == globalSet.handle %} class="sel"{% endif %} href="{{ theGlobalSet.getCpEditUrl() }}">{{ theGlobalSet.name|t('site') }}</a></li>
            {% endfor %}
        </ul>
    </nav>
{% endblock %}


{% block content %}
    {{ actionInput('globals/save-content') }}
    {{ hiddenInput('setId', globalSet.id) }}
    {{ hiddenInput('siteId', globalSet.siteId) }}
    {{ csrfInput() }}

    {% if globalSet.getFieldLayout().getTabs()|length %}
        <div id="fields">
            {{ fieldsHtml|raw }}
        </div>
    {% else %}
        {{ "This global set doesn’t have any fields assigned to it in its field layout."|t('app') }}
    {% endif %}

    {# Give plugins a chance to add other things here #}
    {% hook "cp.globals.edit.content" %}
{% endblock %}
