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,7 +119,17 @@ ul.actions li {
.form-control {
border: 1px solid #ccc;
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 {
display: block;;
@ -151,7 +161,7 @@ textarea {
}
.form-inline .form-group {
vertical-align: middle;
vertical-align: top;
display: inline-block;
margin-bottom: 0;
}
@ -160,14 +170,6 @@ textarea {
min-width: 15em;
}
.form-inline .checkbox .form-control {
min-width: auto;
}
.form-inline .checkbox label {
padding-right: 1em;
}
.form-inline .form-control.select2 {
display: inline-block;
}

View File

@ -4,7 +4,7 @@
{% if field.field.required %} required{% 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 %}
{{ field }}

View File

@ -7,12 +7,13 @@ from django.urls import reverse
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:
return str(field)
classes = field.field.widget.attrs.get('class', '').split(' ')
classes.append('form-control')
if css:
classes.append(css)