{% extends "base.html" %}
{% load static %}
{% block title %}
    更新文章
{% endblock title %}
{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-12">
                <br>
                <form method="post" action="." enctype="multipart/form-data">
                    {% csrf_token %}
                    <div class="form-group">
                        <label for="title">
                            文章标题
                        </label>
                        <input type="text" class="form-control" id="title" name="title" value="{{ article.title }}">
                    </div>
                    {% if article.avatar %}
                        <label for="body">
                            标题图
                        </label>
                        <div class="col-3">
                            <img src="{{ article.avatar.url }}"
                                 alt="avatar"
                                 style="max-width: 100%; border-radius: 20px;"
                            >
                        </div>
                    {% else %}
                        <div class="form-group">
                            <label for="avatar">标题图</label>
                            <input type="file" class="form-control-file" name="avatar" id="avatar">
                        </div>
                    {% endif %}
                    <div class="form-group">
                        <label for="column">分类</label>
                        <select class="form-control"
                                id="column"
                                name="column"
                        >
                            <option value="none">请选择分类..</option>
                            {% for column in columns %}
                                <option value="{{ column.id }}"
                                        {% if column.id == article.column.id %}
                                        selected
                                        {% endif %}
                                >
                                    {{ column }}
                                </option>
                            {% endfor %}
                        </select>
                    </div>
                    <!--标签-->
                    <div class="form-group">
                        <label for="tags">标签</label>
                        <input type="text" class="form-control col-3" id="tags" name="tags" value="{{ tags }}">
                    </div>
                    <div class="form-group">
                        <label for="body">
                            文章正文
                        </label>
                        <textarea type="text" class="form-control" id="body" name="body" rows="12">
                        {{ article.body }}
                    </textarea>
                    </div>
                    <button type="submit" class="btn btn-primary">
                        提交
                    </button>
                </form>
            </div>
        </div>
    </div>
{% endblock content %}