From 404d8287115ab30e8e81daedd1a93ebc6cd0d2ca Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Thu, 3 Oct 2024 19:26:40 +0100 Subject: [PATCH] Allow form.widgets.RenderTemplateWidget to use the theme object --- flask_admin/base.py | 2 ++ flask_admin/form/widgets.py | 1 + 2 files changed, 3 insertions(+) diff --git a/flask_admin/base.py b/flask_admin/base.py index 3ac8c31d1..749e9ff15 100644 --- a/flask_admin/base.py +++ b/flask_admin/base.py @@ -548,6 +548,8 @@ def __init__(self, app=None, name=None, # 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 e1ef745a5..1454d644f 100644 --- a/flask_admin/form/widgets.py +++ b/flask_admin/form/widgets.py @@ -90,6 +90,7 @@ def __call__(self, field, **kwargs): '_gettext': gettext, '_ngettext': ngettext, 'h': h, + 'theme': current_app.config['theme'], }) template = current_app.jinja_env.get_template(self.template)