{% extends 'base.html' %}

{% block content %}
    <h1>This is the home page</h1>
    <p>Here we have have several things.</p>

    {% for field, message in context_form.errors.items() %}
        <div class="alert alert-dismissible fade show" role="alert">
        <b>{{ field }}</b>: {{ message }}
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>

    {% endfor %}

    <h2>Select the working context</h2>
    <form id="select_context" method="POST">
        {{ context_form.hidden_tag() }}
        <fieldset class="form-group">
            <div class="input-group mb-3">

                {% if context_form.context.errors %}
                    {{ context_form.context(class="form-select is-invalid") }}
                    <div class="invalid-feedback">
                        {% for error in context_form.context.errors %}
                            <span>{{ error }}</span>
                        {% endfor %}
                    </div>
                {% else %}
                    {{ context_form.context(class="form-select") }}
                {% endif %}

                {{ context_form.submit(class='btn btn-primary') }}
            </div>
        </fieldset>
    </form>

{% endblock %}