Add django-crispy-forms for BS4 support
TODO: Remove django-bootstrap-form dependency, left to avoid breaking other parts.
This commit is contained in:
parent
70138d0433
commit
1f04ec0cea
3 changed files with 54 additions and 0 deletions
|
@ -234,8 +234,12 @@ INSTALLED_APPS = [
|
|||
# testing and rollout
|
||||
"django_nose",
|
||||
"waffle",
|
||||
|
||||
"crispy_forms",
|
||||
]
|
||||
|
||||
CRISPY_TEMPLATE_PACK = "bootstrap4"
|
||||
|
||||
DEBUG_TOOLBAR_PANELS = [
|
||||
'debug_toolbar.panels.versions.VersionsPanel',
|
||||
'debug_toolbar.panels.timer.TimerPanel',
|
||||
|
|
48
pinaxcon/templates/bootstrap4/field.html
Normal file
48
pinaxcon/templates/bootstrap4/field.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
{% load crispy_forms_field %}
|
||||
|
||||
{% if field.is_hidden %}
|
||||
{{ field }}
|
||||
{% else %}
|
||||
{% if field|is_checkbox %}
|
||||
<div class="form-group{% if 'form-horizontal' in form_class %} row{% endif %}">
|
||||
{% if label_class %}
|
||||
<div class="{% for offset in bootstrap_checkbox_offsets %}{{ offset }} {% endfor %}{{ field_class }}">
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="{% if not field|is_checkbox %}form-group{% if 'form-horizontal' in form_class %} row{% endif %}{% else %}form-check{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
|
||||
{% if field.label and not field|is_checkbox and form_show_labels %}
|
||||
<label for="{{ field.id_for_label }}" class="col-form-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
|
||||
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
|
||||
</label>
|
||||
{% 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 %}
|
||||
<label for="{{ field.id_for_label }}" class="form-check-label{% if field.field.required %} requiredField{% endif %}">
|
||||
{% crispy_field field 'class' 'form-check-input' %}
|
||||
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
|
||||
</label>
|
||||
{% include 'bootstrap4/layout/help_text_and_errors.html' %}
|
||||
{% else %}
|
||||
<div class="{{ field_class }}">
|
||||
{% include 'bootstrap4/layout/help_text_and_errors.html' %}
|
||||
{% crispy_field field %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</{% if tag %}{{ tag }}{% else %}div{% endif %}>
|
||||
{% if field|is_checkbox %}
|
||||
{% if label_class %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
|
@ -49,3 +49,5 @@ django-waffle>=0.12.0
|
|||
libsass==0.14.5
|
||||
django-sass-processor==0.7
|
||||
django-compressor==2.2
|
||||
|
||||
django-crispy-forms
|
Loading…
Reference in a new issue