{% extends "one_column_body.html" %}
{% block content %}
<h1 class="section-title">
    {% trans %}Settings{% endtrans %} &rarr; {{ settings_group.super_group.name }} &rarr; {{ settings_group.name }}
</h1>
<div class="settings-main">
{% if form.errors %}
    <p class="errornote">
    {% trans counter = form.errors|length %}Please correct the error below.{% pluralize %}Please correct the errors below.{% endtrans %}
    </p>
{% endif %}
{% if form.fields %}
<form method="post" enctype="multipart/form-data">{% csrf_token %}
    <table 
        class="settings"
        summary="{% trans name = settings_group.name %}Settings included in {{ name }}.{% endtrans %}"
    >
        {% for field in form %}
            {% if field.is_hidden %}
                <!-- skip hidden field {{field.key}} -->
            {% else %}
                {% if field.errors %}
                <tr class="error">
                    <td colspan="2">{{ field.errors }}</td>
                </tr>
                {% endif %}
                <tr{% if field.errors %} class="error"{% endif %}>
                    <td class="setting-label">
                        <label for="{{ field.name }}">{{ field.label }}</label>
                        {% if field.help_text %}
                            <p class="help">{{ field.help_text|safe }}</p>
                        {% endif %}
                        {% if field.field.default_text %}
                            <p class="help">{{ field.field.default_text|safe }}</p>
                        {% endif %}
                    </td>
                    <td class="setting-input">{{ field }}</td>
                </tr>
            {% endif %}
        {% endfor %}
    </table>
    {% for field in form %}
        {% if field.is_hidden %}
            {{field}}
        {% endif %}
    {% endfor %}
    <input type="submit" value="{% trans %}Save{% endtrans %}" class="default" />
</form>
{% else %}
    <p>{% trans %}You don't have permission to edit values.{% endtrans %}</p>
{% endif %}
</div>
{% if all_super_groups %}
    <div class="settings-nav">
    {% for super_group in all_super_groups %}
        <h2>{{ super_group.name }}</h2>
        <ul>
        {% for g in super_group.groups %}
            {% if g.keys %}
                {% if g.key == settings_group.key %}
                    <li class="on">{{g.name}}</li>
                {% else %}
                    <li><a href="{% url "group_settings" g.key %}">{{g.name}}</a></li>
                {% endif %}
            {% endif %}
        {% endfor %}
        </ul>
    {% endfor %}
    </div>
{% endif %}
<div class="clearfix"></div>
{% endblock %}
