From 728e908b4f50f94bb63674311bfa108c096f9dd6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 18 Jan 2018 17:05:45 +0100 Subject: Add a bs_field template tag --- .../templates/blocks/bs_field_snippet.html | 26 ++++++++++++++++++++++ .../templates/blocks/bs_form_snippet.html | 4 ++-- ishtar_common/templatetags/table_form.py | 7 ++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 ishtar_common/templates/blocks/bs_field_snippet.html (limited to 'ishtar_common') diff --git a/ishtar_common/templates/blocks/bs_field_snippet.html b/ishtar_common/templates/blocks/bs_field_snippet.html new file mode 100644 index 000000000..bf341db8e --- /dev/null +++ b/ishtar_common/templates/blocks/bs_field_snippet.html @@ -0,0 +1,26 @@ +{% load i18n %} +
+ {{ field.label_tag }} + {% if field.help_text %} +
+ {% endif %} + {{field|safe}} + {% if field.help_text %} + + + +
+
+
+ {{field.help_text}} +
+
+ {% endif %} + {% if field.errors %}
+ {{ field.errors }} +
{% endif %} +
diff --git a/ishtar_common/templates/blocks/bs_form_snippet.html b/ishtar_common/templates/blocks/bs_form_snippet.html index eb52fa653..a9042ff67 100644 --- a/ishtar_common/templates/blocks/bs_form_snippet.html +++ b/ishtar_common/templates/blocks/bs_form_snippet.html @@ -7,8 +7,8 @@ {% for hidden in form.hidden_fields %} {{hidden}} -{% if field.errors %}
- {{ field.errors }} +{% if hidden.errors %}
+ {{ hidden.errors }}
{% endif %} {% endfor %} diff --git a/ishtar_common/templatetags/table_form.py b/ishtar_common/templatetags/table_form.py index ad99516a5..0ebd8443e 100644 --- a/ishtar_common/templatetags/table_form.py +++ b/ishtar_common/templatetags/table_form.py @@ -17,6 +17,13 @@ def table_form(form): return {'form': form} +@register.inclusion_tag('blocks/bs_field_snippet.html') +def bs_field(field, required=False, label=None): + if label: + label = _(label) + return {'field': field, 'required': required, 'label': label} + + @register.inclusion_tag('blocks/table_field.html') def table_field(field, required=False, label=None): if label: -- cgit v1.2.3