From c01d81b2fe42c0a2d7083363871fb3b956fc84de Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Fri, 26 Aug 2016 10:40:18 -0700 Subject: [PATCH] Added bootstrap4 templates to fix Crispy Forms --- .../templates/bootstrap4/field.html | 48 +++++++++++++++++++ .../bootstrap4/layout/field_errors_block.html | 5 ++ 2 files changed, 53 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/field.html create mode 100644 {{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/layout/field_errors_block.html diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/field.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/field.html new file mode 100644 index 00000000..8e092a70 --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/field.html @@ -0,0 +1,48 @@ +{% load crispy_forms_field %} + +{% if field.is_hidden %} + {{ field }} +{% else %} + {% if field|is_checkbox %} +
+ {% if label_class %} +
+ {% endif %} + {% endif %} + <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" {% if not field|is_checkbox %}class="form-group{% if using_grid_layout %} row{% endif %}{% else %}class="checkbox{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-danger{% endif %}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}"> + {% if field.label and not field|is_checkbox and form_show_labels %} + + {% endif %} + + {% if field|is_checkboxselectmultiple %} + {% include 'bootstrap4/layout/checkboxselectmultiple.html' %} + {% endif %} + + {% if field|is_radioselect %} + {% include 'bootstrap4/layout/radioselect.html' %} + {% endif %} + + {% if not field|is_checkboxselectmultiple and not field|is_radioselect %} + {% if field|is_checkbox and form_show_labels %} + + {% else %} +
+ {% crispy_field field %} +
+ {% include 'bootstrap4/layout/help_text_and_errors.html' %} + {% endif %} + {% endif %} + + {% if field|is_checkbox %} + {% if label_class %} +
+ {% endif %} +
+ {% endif %} +{% endif %} diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/layout/field_errors_block.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/layout/field_errors_block.html new file mode 100644 index 00000000..1986dccc --- /dev/null +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/bootstrap4/layout/field_errors_block.html @@ -0,0 +1,5 @@ +{% if form_show_errors and field.errors %} + {% for error in field.errors %} +

{{ error }}

+ {% endfor %} +{% endif %}