{% extends 'punkweb_bb/base.html' %}
{% load static %}

{% block title_prefix %}Edit Thread | {% endblock %}

{% block extra_head %}
{{form.media.css}}
<link rel="stylesheet" href="{% static 'punkweb_bb/css/thread-form.css' %}" />
{% endblock %}

{% block content %}

<nav>
  <ul class="pw-breadcrumb">
    <li class="pw-breadcrumb-item">
      <a href="{% url 'punkweb_bb:index' %}">Home</a>
    </li>
    <li class="pw-breadcrumb-item">
      <a href="{{thread.subcategory.category.get_absolute_url}}">{{thread.subcategory.category.name}}</a>
    </li>
    <li class="pw-breadcrumb-item">
      <a href="{{thread.subcategory.get_absolute_url}}">{{thread.subcategory.name}}</a>
    </li>
    <li class="pw-breadcrumb-item">
      <a href="{{thread.get_absolute_url}}">{{thread.title}}</a>
    </li>
    <li class="pw-breadcrumb-item active">
      Edit
    </li>
  </ul>
</nav>

<div class="pw-card fluid">
  <div class="pw-card-header">Edit Thread</div>
  <div class="pw-card-content">
    <form class="threadForm" action="{% url 'punkweb_bb:thread_update' thread.id %}" method="post">
      {% csrf_token %}
      {% for field in form %}
      <div class="threadForm__field">
        <label class="pw-input-label" for="{{ field.id_for_label }}">{{ field.label }}</label>
        {{ field }}
      </div>
      {% endfor %}
      {% if form.non_field_errors %}
      {{ form.non_field_errors }}
      {% endif %}
      <div class="threadForm__actions">
        <a class="pw-button default" href="{{thread.get_absolute_url}}">Cancel</a>
        <button class="pw-button raised primary" type="submit">Save</button>
      </div>
    </form>
  </div>
</div>

{% endblock %}

{% block extra_script %}
{{form.media.js}}
{% endblock %}