Changed to WTForms including validation

This commit is contained in:
2016-04-18 07:25:40 +02:00
parent 6f218e591f
commit 864b7822ac
3 changed files with 36 additions and 35 deletions

View File

@@ -12,11 +12,11 @@
<div class="col-sm-10">
{{ field(**kwargs)|safe }}
{% if field.errors %}
<ul class=errors>
<p class='error'>
{% for error in field.errors %}
<li>{{ error }}</li>
{{ error }}
{% endfor %}
</ul>
</p>
{% endif %}
</div>
</div>

View File

@@ -3,28 +3,9 @@
{% block body %}
<form class='form-horizontal' method="POST">
{{ form.hidden_tag() }}
<div class="form-group">
<label class="col-sm-2 control-label" for="date">{{ form.date.label }}</label>
<div class="col-sm-10">
{{ form.date(size=20) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="odometer">{{ form.odometer.label }}</label>
<div class="col-sm-10">
{{ form.odometer(size=20) }}
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="litres">{{ form.litres.label }}</label>
<div class="col-sm-10">
{{ form.litres(size=20) }}
</div>
</div>
{{ render_field(form.date) }}
{{ render_field(form.odometer) }}
{{ render_field(form.litres) }}
<input type="submit" value="Go">
</form>