51 lines
2.3 KiB
HTML
51 lines
2.3 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<div class="container mt-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2 class="mb-0">{% if topic is defined %}編輯主題{% else %}新增主題{% endif %}</h2>
|
|
</div>
|
|
<div class="card-body">
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }}">{{ message }}</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<form method="POST">
|
|
<div class="mb-3">
|
|
<label for="section_id" class="form-label">所屬區塊</label>
|
|
<select class="form-select" id="section_id" name="section_id" required>
|
|
<option value="">請選擇區塊</option>
|
|
{% for section in sections %}
|
|
<option value="{{ section.id }}"
|
|
{% if topic is defined and topic.section_id == section.id %}selected{% endif %}>
|
|
{{ section.title }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="title" class="form-label">主題標題</label>
|
|
<input type="text" class="form-control" id="title" name="title"
|
|
value="{{ topic.title if topic is defined else '' }}" required>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="description" class="form-label">主題描述</label>
|
|
<textarea class="form-control" id="description" name="description" rows="3">{{ topic.description if topic is defined else '' }}</textarea>
|
|
</div>
|
|
<div class="mt-4">
|
|
<button type="submit" class="btn btn-primary">
|
|
{% if topic is defined %}保存{% else %}新增{% endif %}
|
|
</button>
|
|
<a href="{{ url_for('main.manage_topics') }}" class="btn btn-secondary">返回</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|