Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Boolean field checkbox UI #88

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sqladmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async def convert(
"filters": [],
"default": None,
"description": prop.doc,
"render_kw": {"class": "form-control"},
}

converter = None
Expand Down Expand Up @@ -173,6 +174,7 @@ def conv_Text(self, field_args: Dict, **kwargs: Any) -> Field:

@converts("Boolean", "dialects.mssql.base.BIT")
def conv_Boolean(self, field_args: Dict, **kwargs: Any) -> Field:
field_args["render_kw"]["class"] = "form-check-input"
return BooleanField(**field_args)

@converts("Date")
Expand Down
2 changes: 1 addition & 1 deletion sqladmin/templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3 class="card-title">New {{ model_admin.name }}</h3>
{% if field.errors %}
{{ field(class_="form-control is-invalid") }}
{% else %}
{{ field(class_="form-control") }}
{{ field() }}
{% endif %}
{% for error in field.errors %}
<div class="invalid-feedback">{{ error }}</div>
Expand Down
2 changes: 1 addition & 1 deletion sqladmin/templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h3 class="card-title">Edit {{ model_admin.name }}</h3>
{% if field.errors %}
{{ field(class_="form-control is-invalid") }}
{% else %}
{{ field(class_="form-control") }}
{{ field() }}
{% endif %}
{% for error in field.errors %}
<div class="invalid-feedback">{{ error }}</div>
Expand Down