Skip to content

Commit

Permalink
Add missing css_class to accordion template
Browse files Browse the repository at this point in the history
  • Loading branch information
flisakl committed Jan 26, 2024
1 parent 668e66d commit 4e06199
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crispy_bootstrap5/templates/bootstrap5/accordion.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="accordion{% if accordion.flush %} accordion-flush{% endif %}" id="{{ accordion.css_id }}">
<div class="accordion{% if accordion.flush %} accordion-flush{% endif %}{% if accordion.css_class %} {{accordion.css_class}}{% endif %}" id="{{ accordion.css_id }}">
{{ content|safe }}
</div>
19 changes: 19 additions & 0 deletions tests/test_layout_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,25 @@ def test_accordion_and_accordiongroup(self):
)
assert parse_form(form) == parse_expected("accordion.html")

def test_accordion_css_class_is_applied_to_accordion(self):
classes = 'one two three'
test_form = SampleForm()
test_form.helper = FormHelper()
test_form.helper.form_tag = False
test_form.helper.layout = Layout(
Accordion(
AccordionGroup("one", "first_name"),
css_class=classes,
css_id='super-accordion'
)
)
html = render_crispy_form(test_form)

assert (
html.count('<div class="accordion %s" id="super-accordion"' % classes)
== 1
)

def test_accordion_active_false_not_rendered(self):
test_form = SampleForm()
test_form.helper = FormHelper()
Expand Down

0 comments on commit 4e06199

Please sign in to comment.