From 6515a0a224036d332f75fbd13388c586cd528360 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 28 Dec 2024 21:18:10 -0600 Subject: [PATCH] fix: use span element for readonly money field widget render --- src/wuttaweb/forms/widgets.py | 4 ++-- tests/forms/test_widgets.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wuttaweb/forms/widgets.py b/src/wuttaweb/forms/widgets.py index 2541195..0af8bab 100644 --- a/src/wuttaweb/forms/widgets.py +++ b/src/wuttaweb/forms/widgets.py @@ -224,9 +224,9 @@ class WuttaMoneyInputWidget(MoneyInputWidget): readonly = kw.get('readonly', self.readonly) if readonly: if cstruct in (colander.null, None): - return "" + return HTML.tag('span') cstruct = decimal.Decimal(cstruct) - return self.app.render_currency(cstruct) + return HTML.tag('span', c=[self.app.render_currency(cstruct)]) return super().serialize(field, cstruct, **kw) diff --git a/tests/forms/test_widgets.py b/tests/forms/test_widgets.py index 71f0dc0..f98210c 100644 --- a/tests/forms/test_widgets.py +++ b/tests/forms/test_widgets.py @@ -131,11 +131,11 @@ class TestWuttaMoneyInputWidget(WebTestCase): # readonly is rendered per app convention result = widget.serialize(field, str(amount), readonly=True) - self.assertEqual(result, '$12.34') + self.assertEqual(result, '$12.34') # readonly w/ null value result = widget.serialize(field, None, readonly=True) - self.assertEqual(result, '') + self.assertEqual(result, '') class TestFileDownloadWidget(WebTestCase):