{% extends "layout.jinja2" %}

{% block pagename %}
    {{ pagename }}
{% endblock pagename %}
{% block css %}
    <style>
        #submit-div {
            width: 25%;
        }
        #select-submit {
            float: right;
            margin: 5px;
        }
    </style>
{% endblock %}
{% block scripts %}
    <script>
        $( function() {
            $('#select-submit').button();
            var select = $('#select-select');
            {% if not displayonly %}
                select.select2({{ select2options }});
                select.val({{ select2val }});
                select.trigger('change');
            {% else %}
                select.text({{ select2val }})
            {% endif %}
        });
    </script>
{% endblock %}
{% block body %}
    {{ preselecthtml|safe }}
    {% if not displayonly %}
    <form id="select-form" class="select-view-form" action="{{ posturl }}", method="post">
        {% if selectlabel %}
            <label for="select-select"><b>{{ selectlabel }}</b></label>
        {% endif %}
        <select id="select-select" name="select-select"></select><br>
        <div id="submit-div">
            <input id="select-submit" type="submit" value="Submit">
        </div>
    </form>
    {% else %}
        <label for="select-select"><b>{{ selectlabel }}</b></label>
        <span id="select-select" name="select-select"></span>
    {% endif %}
{% endblock %}