Skip to content

Commit

Permalink
Rework renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Mar 17, 2021
1 parent 6db2c5e commit ae837e1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/django_bootstrap5/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,12 @@ def get_label_class(self):
label_class = merge_css_classes(label_class, "sr-only")
return label_class

def get_label(self):
def get_label_html(self):
"""Return value for label."""
if self.show_label == "skip":
return None
return self.field.label

def add_label(self, html):
label = self.get_label()
if label:
html = render_label(label, label_for=self.field.id_for_label, label_class=self.get_label_class()) + html
return html
label_html = "" if self.show_label == "skip" else self.field.label
if label_html:
label_html = render_label(label_html, label_for=self.field.id_for_label, label_class=self.get_label_class())
return label_html

def get_form_group_class(self):
form_group_class = self.form_group_class
Expand Down Expand Up @@ -512,13 +507,17 @@ def _render(self):
return ""
if self.field.is_hidden:
return text_value(self.field)
html = self.get_field_html()

field_html = self.get_field_html()
label_html = self.get_label_html()

html = field_html
html = self.post_widget_render(html)
html = self.append_to_checkbox_field(html)
html = self.wrap_widget(html)
html = self.make_input_group(html)
html = self.append_to_field(html)
html = self.wrap_field(html)
html = self.add_label(html)
html = label_html + html
html = self.wrap_label_and_field(html)
return html

0 comments on commit ae837e1

Please sign in to comment.