{% extends "_layouts/cp" %}

{% set fullPageForm = true %}

{% import "_includes/forms" as forms %}

{% block content %}
    <input type="hidden" name="action" value="tags/save-tag-group">
    {{ redirectInput('settings/tags') }}

    {% if tagGroup.id %}<input type="hidden" name="tagGroupId" value="{{ tagGroup.id }}">{% endif %}

    <div id="taggroup-settings">
        {{ forms.textField({
            first: true,
            label: "Name"|t('app'),
            instructions: "What this tag group will be called in the CP."|t('app'),
            id: 'name',
            name: 'name',
            value: tagGroup.name,
            errors: tagGroup.getErrors('name'),
            autofocus: true,
            required: true,
        }) }}

        {{ forms.textField({
            label: "Handle"|t('app'),
            instructions: "How you’ll refer to this tag group in the templates."|t('app'),
            id: 'handle',
            class: 'code',
            name: 'handle',
            value: tagGroup.handle,
            errors: tagGroup.getErrors('handle'),
            required: true
        }) }}
    </div>

    <div id="taggroup-fieldlayout" class="hidden">
        {% include "_includes/fieldlayoutdesigner" with {
            fieldLayout: tagGroup.getFieldLayout(),
            customizableTabs: false
        } only %}
    </div>
{% endblock %}


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