Enhance support for inline formsets

This commit is contained in:
Ales (Shagi) Zabala Alava 2021-01-05 16:16:40 +01:00
parent 599742b3e3
commit 8ae1df31d7
3 changed files with 16 additions and 13 deletions

View File

@ -119,6 +119,16 @@ ul.actions li {
.form-control { .form-control {
border: 1px solid #ccc; border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075); box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
width: 100%;
}
.checkbox .form-control {
min-width: auto;
width: auto;
}
.checkbox label {
padding-right: 1em;
} }
.errorlist { .errorlist {
@ -151,7 +161,7 @@ textarea {
} }
.form-inline .form-group { .form-inline .form-group {
vertical-align: middle; vertical-align: top;
display: inline-block; display: inline-block;
margin-bottom: 0; margin-bottom: 0;
} }
@ -160,14 +170,6 @@ textarea {
min-width: 15em; min-width: 15em;
} }
.form-inline .checkbox .form-control {
min-width: auto;
}
.form-inline .checkbox label {
padding-right: 1em;
}
.form-inline .form-control.select2 { .form-inline .form-control.select2 {
display: inline-block; display: inline-block;
} }

View File

@ -4,7 +4,7 @@
{% if field.field.required %} required{% endif %} {% if field.field.required %} required{% endif %}
{% if field.errors %} has-error{% endif %} {% if field.errors %} has-error{% endif %}
"> ">
<label>{{ field.label }}</label> <label for="{{ field.id_for_label }}">{{ field.label }}</label>
{% add_widget_attrs field placeholder=field.label %} {% add_widget_attrs field placeholder=field.label %}
{{ field }} {{ field }}

View File

@ -7,12 +7,13 @@ from django.urls import reverse
register = template.Library() register = template.Library()
def base_form_field(field, css='form-control', container_class='', add_another_url=None, field_template=None): def base_form_field(field, css=None, container_class='', add_another_url=None, field_template=None):
if field.is_hidden: if field.is_hidden:
return str(field) return str(field)
classes = field.field.widget.attrs.get('class', '').split(' ') classes = field.field.widget.attrs.get('class', '').split(' ')
classes.append('form-control')
if css: if css:
classes.append(css) classes.append(css)