{% extends 'base.html' %}

{% block content %}
<h1>{% block category_name %} Create a New Item {% endblock %}</h1>

<form method="post">

    <!-- {# content #} -->
    <div class="form-group">
        <label for="content">Content</label>
        <input type="text" name="content"
               placeholder="Todo content" class="form-control"
               value="{{ request.form['content'] }}"></input>
    </div>


    <!-- {# category #} -->
    <div class="form-group">
        <label for="cat">category/type</label>
        <select class="form-control" name="cat">
            <option value="New category" selected>New category</option>
            {% for cat in categories %}
                {% if cat['category_name'] == request.form['cat'] %}
                    <option value="{{ request.form['cat'] }}" selected>
                        {{ request.form['cat'] }}
                    </option>
                {% else %}
                    <option value="{{ cat['category_name'] }}">
                        {{ cat['category_name'] }}
                    </option>
                {% endif %}
            {% endfor %}
        </select>
    </div>
    <div class="form-group">
        <label for="new_category">New Category</label>
        <input type="text" name="new_category"
                placeholder="New category name" class="form-control"
                value="{{ request.form['new_category'] }}"></input>
    </div>


    <!-- {# topic #} -->
    <div class="form-group">
        <label for="topic_tag">topic_tag</label>
        <select class="form-control" name="topic_tag">
            <option value="{{ request.form['topic_tag'] }}" selected> --- </option>
            <option value="New topic">New topic</option>
            {% for topic in topics %}
                {% if topic['content'] == request.form['topic_tag'] %}
                    <option value="{{ request.form['topic_tag'] }}" selected>
                        {{ request.form['topic_tag'] }}
                    </option>
                {% else %}
                    <option value="{{ topic['content'] }}">
                        {{ topic['content'] }}
                    </option>
                {% endif %}
            {% endfor %}
        </select>
    </div>
    <div class="form-group">
        <label for="new_topic">New topic</label>
        <input type="text" name="new_topic"
                placeholder="New topic name" class="form-control"
                value="{{ request.form['new_topic'] }}"></input>
    </div>



    <div class="form-group">
        <button type="submit" class="btn btn-primary">Submit</button>
    </div>
</form>
{% endblock %}

