Skip to content

Commit

Permalink
Merge pull request #591 from CodigoSur/multifield_bootstrap
Browse files Browse the repository at this point in the history
Fixes #478 bug about missing multifield template in bootstrap3
  • Loading branch information
Carlton Gibson committed Feb 22, 2017
2 parents 7f37618 + c466bb9 commit 96889db
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 21 deletions.
40 changes: 19 additions & 21 deletions crispy_forms/templates/bootstrap3/layout/multifield.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{% load crispy_forms_field %}
<div {% if multifield.css_id or errors %}id="{{ multifield.css_id }}"{% endif %}
{% if multifield.css_class %}class="{{ multifield.css_class }}"{% endif %}
{{ multifield.flat_attrs|safe }}>

{% if field.is_hidden %}
{{ field }}
{% else %}

{% if field.label %}
<label for="{{ field.id_for_label }}"{% if labelclass %} class="{{ labelclass }}"{% endif %}>
{% endif %}

{% if field|is_checkbox %}
{% crispy_field field %}
{% if form_show_errors %}
<div class="alert alert-danger" role="alert">
{% for field in multifield.bound_fields %}
{% if field.errors %}
{% for error in field.errors %}
<p id="error_{{ forloop.counter }}_{{ field.auto_id }}">{{ error }}</p>
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% endif %}

{% if field.label %}
{{ field.label }}
{% if multifield.label_html %}
<p {% if multifield.label_class %}class="{{ multifield.label_class }}"{% endif %}>{{ multifield.label_html|safe }}</p>
{% endif %}

{% if not field|is_checkbox %}
{% crispy_field field %}
{% endif %}

{% if field.label %}
</label>
{% endif %}
<div class="multiField">
{{ fields_output|safe }}
</div>

{% endif %}
</div>
39 changes: 39 additions & 0 deletions crispy_forms/templates/bootstrap3/multifield.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% load crispy_forms_field %}

{% if field.is_hidden %}
{{ field }}
{% else %}

{% if field|is_checkbox %}
{% if field.errors %}<div class="has-error">{% endif %}
<div class="checkbox">
{% if field.label %}
<label for="{{ field.id_for_label }}"{% if labelclass %} class="{{ labelclass }}"{% endif %}>
{% endif %}

{% crispy_field field %}
{{ field.label }}

{% if field.label %}
</label>
{% endif %}
{% if field.help_text %}
<p id="help_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</span>
{% endif %}
</div>
{% if field.errors %}</div>{% endif %}
{% else %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{% if field.label %}
<label class="control-label" for="{{ field.id_for_label }}"{% if labelclass %} class="{{ labelclass }}"{% endif %}>
{{ field.label }}
</label>
{% endif %}
{% crispy_field field %}
{% if field.help_text %}
<span id="help_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</span>
{% endif %}
</div>
{% endif %}

{% endif %}

0 comments on commit 96889db

Please sign in to comment.