blob: 92748be4b8ac2674c900d80110acd3440f661408 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
{# -*- mode: web; -*- #}
{% extends "base.html" %}
{% block title %}Add a new invoice{% endblock %}
{% block content %}
{% if message %}
{# the form was submitted and message exists #}
<p><strong>{{ item }}</strong></p>
{# links #}
<p><a href="{{ url_for('add_item', item=item) }}" class="button">Submit another {{ item }}</a></p>
<p><a href="/fapg/home">Return to the index</a></p>
{% else %}
{# the form is displayed when template opens via GET not POST #}
{# show flash - based on WTForms validators see
https://pythonprogramming.net/flash-flask-tutorial/
get_flashed_messages() exists here because of flash() in the route
function #}
{% with errors = get_flashed_messages() %} {% if errors %}
{% for err in errors %}
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{ err }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{# end of flash #}
{# the form #}
<form action="{{ url_for('add_item', item=item) }}" method="POST">
<fieldset>
<legend>Add a new {{ item }} to our database.</legend>
{% for field in form %}
{{ field.label() }}
{{ field() }}<br/>
{% endfor %}
</fieldset>
</form>
{% endif %}
{% endblock %}
|