{% extends "assistant/base.html" %}

{%  block container %} 

  <div class="col-md-6 col-md-offset-3">
    <form method="POST">
      {% if form.is_bound and not form.is_valid %}
	<div class="alert alert-danger">
	  {% for field in form %}
	    {% if field.errors %}
	      <p><b>{{ field.name }}</b></p>
	      <ul>
		{% for error in field.errors %}
		  <li>{{ error }}</li>
		{% endfor %}
	      </ul>
	    {% endif %}
	  {% endfor %}
	</div>
      {% endif %}

      {% csrf_token %}

      <div class="form-group">
	<input name="title" type="text" class="form-control" placeholder="Title" value="{{ test.title }}">
      </div>

      <div class="form-group">
	<p class="help-block">This field support the <a href="http://daringfireball.net/projects/markdown/syntax">markdown syntax</a></p>
	<textarea id="description" name="description" class="form-control" placeholder="Description">{{ test.description }}</textarea>
      </div>

      <div class="tags">
	<ul>
	  {% for tag in tags %}
	    <li {% if tag.name in test.tags.names %}selected="selected"{% endif %}>{{ tag.name }}</li>
	  {% endfor %}
	</ul>
	<input type="hidden" name="tags" value="{% for tag in test.tags.names %}{{ tag }},{% endfor %}" />
      </div>
      
      <button type="submit" class="btn btn-primary btn-block">Submit</button>
    </form>
  </div>
  <!-- javascript -->
{% endblock %}
