Appearance: Fix form CSS media rendering
Fix the way the form CSS contained in the media attribute is rendered. This is now an interator and not a single value. Replace the current method with a for loop. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
|
||||
{% load appearance_tags %}
|
||||
|
||||
{{ form.media.render_css|safe }}
|
||||
{% for asset in form.media.render_css %}
|
||||
{{ asset|safe }}
|
||||
{% endfor %}
|
||||
|
||||
{% for group, errors in form.errors.items %}
|
||||
{% for error in errors %}
|
||||
@@ -38,83 +40,82 @@
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% else %}
|
||||
|
||||
{% for field in form.hidden_fields %}
|
||||
{{ field }}
|
||||
{% endfor %}
|
||||
{% for field in form.visible_fields %}
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{# We display the label then the field for all except checkboxes #}
|
||||
{% if field|widget_type != 'checkboxinput' and not field.field.widget.attrs.hidden %}
|
||||
{% if not hide_labels %}{{ field.label_tag }}{% if field.field.required and not read_only %} ({% trans 'required' %}){% endif %}{% endif %}
|
||||
{% endif %}
|
||||
{% if field|widget_type == 'checkboxinput' %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input {% if field.value %}checked="checked"{% endif %} name="{% if form.prefix %}{{ form.prefix }}-{% endif %}{{ field.name }}" type="checkbox">
|
||||
{% if not hide_labels %}{{ field.label }}{% if field.field.required and not read_only %} ({% trans 'required' %}){% endif %}{% endif %}
|
||||
</label>
|
||||
</div>
|
||||
{% elif field|widget_type == 'emailinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'textinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'textarea' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'select' %}
|
||||
{% if read_only %}
|
||||
{{ field|get_choice_value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'selectmultiple' %}
|
||||
{% if read_only %}
|
||||
{{ field|get_choice_value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'clearablefileinput' %}
|
||||
{# Don't add 'form-control' class to filebrowse fields #}
|
||||
{% if field.errors %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% else %}
|
||||
{% render_field field class+="" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'radioselect' %}
|
||||
<div class="radio">
|
||||
{% render_field field %}
|
||||
</div>
|
||||
{% elif field|widget_type == 'checkboxselectmultiple' %}
|
||||
{% for option in field %}
|
||||
<div class="checkbox">
|
||||
{{ option }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% elif field|widget_type == 'datetimeinput' or field|widget_type == 'dateinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% for field in form.visible_fields %}
|
||||
<div class="form-group {% if field.errors %}has-error{% endif %}">
|
||||
{# We display the label then the field for all except checkboxes #}
|
||||
{% if field|widget_type != 'checkboxinput' and not field.field.widget.attrs.hidden %}
|
||||
{% if not hide_labels %}{{ field.label_tag }}{% if field.field.required and not read_only %} ({% trans 'required' %}){% endif %}{% endif %}
|
||||
{% endif %}
|
||||
{% if field|widget_type == 'checkboxinput' %}
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input {% if field.value %}checked="checked"{% endif %} name="{% if form.prefix %}{{ form.prefix }}-{% endif %}{{ field.name }}" type="checkbox">
|
||||
{% if not hide_labels %}{{ field.label }}{% if field.field.required and not read_only %} ({% trans 'required' %}){% endif %}{% endif %}
|
||||
</label>
|
||||
</div>
|
||||
{% elif field|widget_type == 'emailinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'textinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'textarea' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'select' %}
|
||||
{% if read_only %}
|
||||
{{ field|get_choice_value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'selectmultiple' %}
|
||||
{% if read_only %}
|
||||
{{ field|get_choice_value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'clearablefileinput' %}
|
||||
{# Don't add 'form-control' class to filebrowse fields #}
|
||||
{% if field.errors %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% else %}
|
||||
{% render_field field class+="" %}
|
||||
{% endif %}
|
||||
{% elif field|widget_type == 'radioselect' %}
|
||||
<div class="radio">
|
||||
{% render_field field %}
|
||||
</div>
|
||||
{% elif field|widget_type == 'checkboxselectmultiple' %}
|
||||
{% for option in field %}
|
||||
<div class="checkbox">
|
||||
{{ option }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% elif field|widget_type == 'datetimeinput' or field|widget_type == 'dateinput' %}
|
||||
{% if read_only %}
|
||||
{{ field.value }}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% render_field field class+="form-control" %}
|
||||
{% endif %}
|
||||
|
||||
{% if field.help_text %}<p class="help-block">{{ field.help_text|safe }}</p>{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if field.help_text %}<p class="help-block">{{ field.help_text|safe }}</p>{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user