From 027aceaf6c8a37a57a51005f849e1ee69352f359 Mon Sep 17 00:00:00 2001 From: Lukas Bockstaller Date: Wed, 27 May 2026 16:20:55 +0200 Subject: [PATCH] add OptionAttrsSelect to allow select options with their own attributes per value --- src/pretix/base/forms/widgets.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pretix/base/forms/widgets.py b/src/pretix/base/forms/widgets.py index 45eb48d872..da9a245b95 100644 --- a/src/pretix/base/forms/widgets.py +++ b/src/pretix/base/forms/widgets.py @@ -269,3 +269,18 @@ class BusinessBooleanRadio(forms.RadioSelect): 'False': False, False: False, }.get(value) + + +class OptionAttrsSelect(forms.Select): + def __init__(self, *args, option_attrs=None, **kwargs): + super().__init__(*args, **kwargs) + self.option_attrs = option_attrs or {} + + def create_option(self, name, value, label, selected, index, subindex=None, attrs=None): + option = super().create_option( + name, value, label, selected, index, subindex=subindex, attrs=attrs + ) + extra = self.option_attrs.get(str(value)) + if extra: + option["attrs"].update(extra) + return option