Skip to content

Field.html does not provide mechanism for overriding bottom margin #218

@nordmichael

Description

@nordmichael

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 %}">

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions