Display errors on invalid forms

It will probably need a bit of styling…
This commit is contained in:
Bat
2018-07-06 19:29:36 +02:00
parent 153400959c
commit 5f3afe900f
12 changed files with 68 additions and 39 deletions
+11 -4
View File
@@ -7,11 +7,18 @@
{% block content %}
<h1>{{ "Create a post" | _ }}</h1>
<form class="new-post" method="post">
<input type="text" class="title" name="title" placeholder="{{ "Title" | _ }}">
<textarea name="content" placeholder="{{ "Content" | _ }}"></textarea>
{{ macros::input(name="title", label="Title", errors=errors, form=form) }}
<label for="license">{{ "License" | _ }}</label>
<input type="text" id="licence" name="license" />
<label for="{{ name }}">{{ label | _ }}</label>
{% if errors is defined and errors.content %}
{% for err in errors.content %}
<p class="error">{{ err.message | _ }}</p>
{% endfor %}
{% endif %}
<textarea name="content" placeholder="{{ "Content" | _ }}" value="{{ form.content | default(value="") }}"></textarea>
{{ macros::input(name="license", label="License", errors=errors, form=form) }}
<input type="submit" value="{{ "Publish" | _ }}" />
</form>