{% import "_includes/forms" as forms %}
{% set fieldNamespace = 'fields'~random() %}
{% set fieldLayout = entryType.getFieldLayout() %}

<form method="post" accept-charset="UTF-8">
    {{ hiddenInput('fieldsLocation', fieldNamespace) }}
    {{ csrfInput() }}

    {% if section.type != 'single' and entryType.hasTitleField %}
        {% set titleField = fieldLayout.getField('title') %}
        {{ forms.textField({
            label: titleField.label ? titleField.label|t('site') : 'Title'|t('app'),
            instructions: titleField.instructions ? titleField.instructions|t('site'),
            attribute: 'title',
            id: 'title'~random(),
            name: 'title',
            required: true,
            first: true
        }) }}
    {% endif %}

    {% namespace fieldNamespace %}
        {% for field in fieldLayout.getFields() %}
            {% if field.required or field.id in widget.fields %}
                {% include "_includes/field" with {
                    field: field,
                    required: field.required,
                    entry: null
                } only %}
            {% endif %}
        {% endfor %}
    {% endnamespace %}

    <div class="buttons">
        <div class="btngroup">
            <button type="submit" class="btn submit">{{ 'Save'|t('app') }}</button>

            <button type="button" class="btn submit menubtn" aria-label="{{ 'Options'|t('app') }}"></button>
            <div class="menu">
                <ul>
                    <li><a>{{ "Save and continue editing"|t('app') }}</a></li>
                </ul>
            </div>
        </div>
        <div class="spinner hidden"></div>
    </div>
</form>
