Blockchain_KM/app/templates/admin/subtopic_form.html
2024-12-02 01:18:08 +08:00

69 lines
3.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 subtopic 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="topic_id" class="form-label">所屬主題</label>
<select class="form-select" id="topic_id" name="topic_id" required>
<option value="">請選擇主題</option>
{% for topic in topics %}
<option value="{{ topic.id }}"
{% if subtopic is defined and subtopic.topic_id == topic.id %}selected{% endif %}>
{{ topic.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="{{ subtopic.title if subtopic is defined else '' }}" required>
</div>
<div class="mb-3">
<label for="content" class="form-label">內容</label>
<textarea class="form-control" id="content" name="content" rows="5">{{ subtopic.content if subtopic is defined else '' }}</textarea>
</div>
<div class="mb-3">
<label class="form-label">關鍵字</label>
<div class="row">
{% for keyword in keywords %}
<div class="col-md-3 mb-2">
<div class="form-check">
<input class="form-check-input" type="checkbox"
name="keywords" value="{{ keyword.id }}"
id="keyword{{ keyword.id }}"
{% if subtopic is defined and keyword in subtopic.keywords %}checked{% endif %}>
<label class="form-check-label" for="keyword{{ keyword.id }}">
{{ keyword.term }}
</label>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary">
{% if subtopic is defined %}保存{% else %}新增{% endif %}
</button>
<a href="{{ url_for('main.manage_subtopics') }}" class="btn btn-secondary">返回</a>
</div>
</form>
</div>
</div>
</div>
{% endblock %}