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"], } )