diff --git a/flask_admin/base.py b/flask_admin/base.py index 760b73fe0..487bcbd2a 100644 --- a/flask_admin/base.py +++ b/flask_admin/base.py @@ -598,6 +598,8 @@ def __init__( # Register with application if app is not None: self._init_extension() + # Make theme available via current_app + app.config["theme"] = self.theme def _validate_admin_host_and_subdomain(self): if self.subdomain is not None and self.host is not None: diff --git a/flask_admin/form/widgets.py b/flask_admin/form/widgets.py index 495066206..9f67aebee 100644 --- a/flask_admin/form/widgets.py +++ b/flask_admin/form/widgets.py @@ -108,6 +108,7 @@ def __call__(self, field, **kwargs): "_gettext": gettext, "_ngettext": ngettext, "h": h, + "theme": current_app.config["theme"], } ) diff --git a/flask_admin/templates/bootstrap4/admin/lib.html b/flask_admin/templates/bootstrap4/admin/lib.html index 5dfe0b084..5f2afff5e 100644 --- a/flask_admin/templates/bootstrap4/admin/lib.html +++ b/flask_admin/templates/bootstrap4/admin/lib.html @@ -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) %} -