{% extends 'manage/changelog/master.twig' %}
{% from 'macros.twig' import container_title %}
{% from '_layout/input.twig' import input_csrf, input_text, input_checkbox %}

{% block manage_content %}
    <div class="container">
        <form action="{{ url('manage-changelog-tag', {'tag': edit_tag.id|default(0)}) }}" method="post">
            {{ input_csrf() }}

            {{ container_title(edit_tag.id is defined ? 'Editing ' ~ edit_tag.name ~ ' (' ~ edit_tag.id ~ ')' : 'Adding a new tag') }}

            <label class="form__label" style="width:100%">
                <div class="form__label__text">Name</div>
                <div class="form__label__input">
                    {{ input_text('tag[name]', '', edit_tag.id is defined ? edit_tag.name : '', 'text', '', true, {'maxlength':255}) }}
                </div>
            </label>

            <label class="form__label" style="width:100%">
                <div class="form__label__text">Description</div>
                <div class="form__label__input">
                    <textarea class="input__textarea" name="tag[description]" maxlength="65535">{{ edit_tag.description|default('') }}</textarea>
                </div>
            </label>

            <label class="form__label">
                <div class="form__label__text">Archived</div>
                <div class="form__label__input">
                    {{ input_checkbox('tag[archived]', '', edit_tag.archived|default(false)) }}
                </div>
            </label>

            {% if edit_tag.id is defined %}
                <label class="form__label">
                    <div class="form__label__text">Created</div>
                    <div class="form__label__input">
                        {{ input_text('', '', edit_tag.createdTime|date('r')) }}
                    </div>
                </label>
            {% endif %}

            <div>
                <button class="input__button">Save</button>
            </div>
        </form>
    </div>
{% endblock %}
