{% extends '_layouts/cp.twig' %}
{% set fullPageForm = true %}

{% import '_includes/forms.twig' as forms %}


{% block content %}
    {{ actionInput('globals/save-set') }}
    {{ redirectInput('settings/globals') }}

    {% if globalSet.id %}{{ hiddenInput('setId', globalSet.id) }}{% endif %}

    {{ forms.textField({
        first: true,
        label: "Name"|t('app'),
        instructions: "What this global set will be called in the control panel."|t('app'),
        id: 'name',
        name: 'name',
        value: globalSet.name,
        errors: globalSet.getErrors('name'),
        autofocus: true,
        required: true,
    }) }}

    {{ forms.textField({
        label: "Handle"|t('app'),
        instructions: "How you’ll refer to this global set in the templates."|t('app'),
        id: 'handle',
        name: 'handle',
        class: 'code',
        autocorrect: false,
        autocapitalize: false,
        value: globalSet.handle,
        errors: globalSet.getErrors('handle'),
        required: true
    }) }}

    <hr>

    {{ forms.fieldLayoutDesignerField({
        fieldLayout: globalSet.getFieldLayout(),
    }) }}
{% endblock %}


{% if not globalSet.handle %}
    {% js %}
        new Craft.HandleGenerator('#name', '#handle');
    {% endjs %}
{% endif %}
