def METHOD_NAME(self, html):
    attrs = {}
    label = self.get_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
    if self.field.form.is_bound:
        is_valid = len(self.field.errors) == 0
    else:
        is_valid = None
    if self.is_group_widget:
        label_for = ""
        label_id = "legend-{}".format(self.field.html_name)
    else:
        label_for = self.field.id_for_label
        label_id = ""
    if hasattr(self.field.field, 'question') and self.field.field.question.identifier:
        attrs["data-identifier"] = self.field.field.question.identifier
    html = render_label(
        label,
        label_for=label_for,
        label_class=self.get_label_class(),
        label_id=label_id,
        attrs=attrs,
        optional=not required and not isinstance(self.widget, CheckboxInput),
        is_valid=is_valid
    ) + html
    return html