Skip to content

Commit

Permalink
Add horizontal form support
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmayo committed Oct 3, 2024
1 parent 404d828 commit 7a36bc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flask_admin/templates/bootstrap4/admin/lib.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@
{% set direct_error = h.is_field_error(field.errors) %}
{% set prepend = kwargs.pop('prepend', None) %}
{% set append = kwargs.pop('append', None) %}
<div class="form-group {{ kwargs.get('column_class', '') }}">
<label for="{{ field.id }}" class="col-form-label {% if field.widget.input_type == 'checkbox' %}d-block mb-0{% endif %}">{{ field.label.text }}
<div class="form-group {% if theme.horizontal %}row {% endif %}{{ kwargs.get('column_class', '') }}">
<label for="{{ field.id }}" class="col-form-label {% if theme.horizontal %}col-sm-2 {% endif %}{% if field.widget.input_type == 'checkbox' %}d-block mb-0{% endif %}">{{ field.label.text }}
{% if h.is_required_form_field(field) %}
<strong class="text-danger">&#42;</strong>
{%- else -%}
&nbsp;
{%- endif %}
</label>
{% if prepend or append %}
<div class="input-group">
{% if prepend or append or theme.horizontal %}
<div class="{% if prepend or append %}input-group {% endif %}{% if theme.horizontal %}col-sm-10{% endif %}">
{%- if prepend -%}
<div class="input-group-prepend">
{{ prepend }}
Expand Down Expand Up @@ -162,7 +162,7 @@
{{ field.description|safe }}
</small>
{% endif %}
{% if prepend or append %}
{% if prepend or append or theme.horizontal %}
</div>
{% endif %}
{% if caller %}
Expand Down
1 change: 1 addition & 0 deletions flask_admin/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BootstrapTheme(Theme):
base_template: str = 'admin/base.html'
swatch: str = 'default'
fluid: bool = False
horizontal: bool = False


Bootstrap4Theme = partial(BootstrapTheme, folder='bootstrap4')

0 comments on commit 7a36bc8

Please sign in to comment.