Skip to content

Commit 235c641

Browse files
kosdmitsmithdc1
andauthored
Add missed css_class to TabHolder template (#183)
* Add missed css_class to TabHolder template * Minor fix in test_tab_and_tab_holder test method * Updated CHANGELOG.md * Updated Tests --------- Co-authored-by: David Smith <[email protected]>
1 parent 9a3e43f commit 235c641

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 2024.3 (TBC)
44
* Added support for Django 5.1.
5-
* Fixed `accordion.html` and `accordion-group.html` templates to render `css_class` attribute.
5+
* Fixed `accordion.html`, `accordion-group.html` and `tab.html` templates to render `css_class` attribute.
66
* Dropped support for django-crispy-forms 2.2 and earlier.
77

88
## 2024.2 (2024-02-24)

crispy_bootstrap5/templates/bootstrap5/layout/tab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul{% if tabs.css_id %} id="{{ tabs.css_id }}"{% endif %} class="nav nav-tabs">
1+
<ul{% if tabs.css_id %} id="{{ tabs.css_id }}"{% endif %} class="nav nav-tabs{% if tabs.css_class %} {{ tabs.css_class }}{% endif %}">
22
{{ links|safe }}
33
</ul>
44
<div class="tab-content card-body">
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<form method="post">
2+
<ul class="nav nav-tabs tab-holder-class">
3+
<li class="nav-item"><a class="nav-link active" href="#custom-name" data-bs-toggle="tab">One</a></li>
4+
<li class="nav-item"><a class="nav-link" href="#two" data-bs-toggle="tab">Two</a></li>
5+
</ul>
6+
<div class="tab-content card-body">
7+
<div id="custom-name" class="tab-pane first-tab-class active">
8+
<div id="div_id_first_name" class="mb-3">
9+
<label for="id_first_name" class="form-label requiredField">first name<span
10+
class="asteriskField">*</span></label>
11+
<input type="text" name="first_name" maxlength="5" class="textinput textInput inputtext form-control" required
12+
id="id_first_name">
13+
</div>
14+
</div>
15+
<div id="two" class="tab-pane">
16+
<div id="div_id_password1" class="mb-3">
17+
<label for="id_password1" class="form-label requiredField">password<span class="asteriskField">*</span></label>
18+
<input type="password" name="password1" maxlength="30" class="passwordinput form-control" required
19+
id="id_password1">
20+
</div>
21+
<div id="div_id_password2" class="mb-3">
22+
<label for="id_password2" class="form-label requiredField">re-enter password<span
23+
class="asteriskField">*</span></label>
24+
<input type="password" name="password2" maxlength="30" class="passwordinput form-control" required
25+
id="id_password2">
26+
</div>
27+
</div>
28+
</div>
29+
</form>

tests/test_layout_objects.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -440,30 +440,13 @@ def test_tab_and_tab_holder(self):
440440
"one",
441441
"first_name",
442442
css_id="custom-name",
443-
css_class="first-tab-class active",
443+
css_class="first-tab-class",
444444
),
445445
Tab("two", "password1", "password2"),
446+
css_class="tab-holder-class",
446447
)
447448
)
448-
html = render_crispy_form(test_form)
449-
450-
assert (
451-
html.count(
452-
'<ul class="nav nav-tabs"> <li class="nav-item">'
453-
'<a class="nav-link active" href="#custom-name" data-bs-toggle="tab">'
454-
"One</a></li>"
455-
)
456-
== 1
457-
)
458-
assert html.count("tab-pane") == 2
459-
460-
assert html.count('class="tab-pane first-tab-class active"') == 1
461-
462-
assert html.count('<div id="custom-name"') == 1
463-
assert html.count('<div id="two"') == 1
464-
assert html.count('name="first_name"') == 1
465-
assert html.count('name="password1"') == 1
466-
assert html.count('name="password2"') == 1
449+
assert parse_form(test_form) == parse_expected("test_tab_and_tab_holder.html")
467450

468451
def test_tab_helper_reuse(self):
469452
# this is a proper form, according to the docs.

0 commit comments

Comments
 (0)