mirror of
https://github.com/pretix/pretix.git
synced 2026-04-23 23:22:32 +00:00
Fix checkbox-labels always containing text "required" although not being required
This commit is contained in:
committed by
GitHub
parent
21c273854c
commit
ca12cbb69e
@@ -60,8 +60,8 @@ def render_label(content, label_for=None, label_class=None, label_title='', labe
|
||||
# => remove for-attribute as well as "required"-text appended to label
|
||||
if 'for' in attrs:
|
||||
del attrs['for']
|
||||
else:
|
||||
opt += '<i class="sr-only label-required">, {}</i>'.format(pgettext('form', 'required')) if not optional else ''
|
||||
elif not optional:
|
||||
opt += '<i class="sr-only label-required">, {}</i>'.format(pgettext('form', 'required'))
|
||||
|
||||
builder = '<{tag}{attrs}>{content}{opt}</{tag}>'
|
||||
return format_html(
|
||||
@@ -155,17 +155,28 @@ class CheckoutFieldRenderer(FieldRenderer):
|
||||
label_class=self.get_label_class(),
|
||||
label_id=label_id,
|
||||
attrs=attrs,
|
||||
optional=not required and not isinstance(self.widget, CheckboxInput),
|
||||
optional=not required,
|
||||
is_valid=is_valid
|
||||
) + html
|
||||
return html
|
||||
|
||||
def put_inside_label(self, html):
|
||||
content = "{field} {label}".format(field=html, label=self.label)
|
||||
|
||||
if hasattr(self.field.field, '_show_required'):
|
||||
# e.g. payment settings forms where a field is only required if the payment provider is active
|
||||
required = self.field.field._show_required
|
||||
elif hasattr(self.field.field, '_required'):
|
||||
# e.g. payment settings forms where a field is only required if the payment provider is active
|
||||
required = self.field.field._required
|
||||
else:
|
||||
required = self.field.field.required
|
||||
|
||||
return render_label(
|
||||
content=mark_safe(content),
|
||||
label_for=self.field.id_for_label,
|
||||
label_title=escape(strip_tags(self.field_help)),
|
||||
optional=not required,
|
||||
)
|
||||
|
||||
def wrap_label_and_field(self, html):
|
||||
|
||||
Reference in New Issue
Block a user