Skip to content

Commit

Permalink
Fix field_class does nothing #287 (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezfauste committed Nov 14, 2023
1 parent e755ab2 commit af68155
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/django_bootstrap5/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def add_widget_class_attrs(self, widget=None):
size_prefix = None

before = []
classes = [widget.attrs.get("class", "")]
classes = [widget.attrs.get("class", ""), text_value(self.field_class)]

if ReadOnlyPasswordHashWidget is not None and isinstance(widget, ReadOnlyPasswordHashWidget):
before.append("form-control-static")
Expand Down
4 changes: 4 additions & 0 deletions tests/test_bootstrap_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def test_placeholder(self):
self.assertIn('type="text"', html)
self.assertIn('placeholder="placeholdertest"', html)

def test_field_class(self):
html = self.render("{% bootstrap_field form.subject field_class='field-class-test' %}", {"form": SubjectTestForm()})
self.assertIn('class="form-control field-class-test"', html)

def test_xss_field(self):
html = self.render("{% bootstrap_field form.xss_field %}", {"form": XssTestForm()})
self.assertIn('type="text"', html)
Expand Down

0 comments on commit af68155

Please sign in to comment.