django-crispy-forms / django-crispy-forms/crispy-bootstrap5
Field.html does not provide mechanism for overriding bottom margin
- Dominant language
- HTML
- Stars
- 525
- Forks
- 77
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 2
Description
the 'field.html' template provides no mechanism for overriding the bottom margin, even when a wrapper_class is passed in that should override the default margin.
for example, passing in a wrapper class of mb-0 will result in a css_class applied to the field of class="mb-3 mb-0"
due to parsing order preference in bootstrap, this means a field will always have a bottom margin of three, even when the user would prefer a larger or smaller one.
I propose modifying the field.html template to look for 'mb-', 'my-', and 'm-' and excluding mb-3 if a matching case is found.
Replacing line 12 of field.html with something like the following should resolve the issue
` <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="{% if field|is_checkbox and form_show_labels %}form-check{% else %}{% if wrapper_class and ' mb-' in ' '|add:wrapper_class or wrapper_class and ' my-' in ' '|add:wrapper_class or wrapper_class and ' m-' in ' '|add:wrapper_class %}{% else %}mb-3{% endif %}{% if 'form-horizontal' in form_class %} row{% endif %}{% endif %}{% if wrapper_class %}{{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.