From 7770ce15ed6a4768044c7f91a9ab4cd323832546 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Mon, 5 Oct 2015 10:55:08 -0700 Subject: [PATCH 1/2] Adds Bootstrap 4 classes as crispy-forms override #365 --- .../templates/bootstrap3/field.html | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html new file mode 100644 index 000000000..a469b988e --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/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 row{% else %}class="checkbox{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-error{% 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 'bootstrap3/layout/checkboxselectmultiple.html' %} + {% endif %} + + {% if field|is_radioselect %} + {% include 'bootstrap3/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 'bootstrap3/layout/help_text_and_errors.html' %} +
+ {% endif %} + {% endif %} + + {% if field|is_checkbox %} + {% if label_class %} +
+ {% endif %} +
+ {% endif %} +{% endif %} From 237ef94e488c23675e7a75c530a511eb731387b2 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Mon, 5 Oct 2015 11:00:33 -0700 Subject: [PATCH 2/2] Use endraw to avoid breaking the build --- .../templates/bootstrap3/field.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html index a469b988e..ba5c9d28e 100644 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/templates/bootstrap3/field.html @@ -1,4 +1,4 @@ -{% load crispy_forms_field %} +{% raw %}{% load crispy_forms_field %} {% if field.is_hidden %} {{ field }} @@ -45,4 +45,4 @@ {% endif %} {% endif %} -{% endif %} +{% endif %}{% endraw %}