Skip to content

Commit

Permalink
Move radio checkbox select help text out of div (#123)
Browse files Browse the repository at this point in the history
Currently, the help text is included in the div, if a scroll class is added to `field_class`,
it will result in the errors and help text being shown as part of the scroll and have to
scroll to the bottom of the inner container to see it. This likely won't be surprising as
the other fields, the help text are beside the input and not within the input container.
  • Loading branch information
pickfire committed Sep 28, 2022
1 parent 05ba4f6 commit 521514e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
</div>
{% endfor %}
{% endfor %}
{% if field.errors and inline_class %}
{% for error in field.errors %}
<p id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="text-danger mb-0"><small><strong>{{ error }}</strong></small></p>
{% endfor %}
{% endif %}

{% include 'bootstrap5/layout/help_text.html' %}
</div>
{% if field.errors and inline_class %}
{% for error in field.errors %}
<p id="error_{{ forloop.counter }}_{{ field.auto_id }}" class="text-danger mb-0"><small><strong>{{ error }}</strong></small></p>
{% endfor %}
{% endif %}
{% include 'bootstrap5/layout/help_text.html' %}
4 changes: 3 additions & 1 deletion tests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ class GroupedChoiceForm(forms.Form):
("unknown", "Unknown"),
]
checkbox_select_multiple = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=choices
widget=forms.CheckboxSelectMultiple,
choices=choices,
help_text="help",
)
radio = forms.MultipleChoiceField(widget=forms.RadioSelect, choices=choices)

Expand Down
5 changes: 4 additions & 1 deletion tests/results/test_grouped_checkboxes.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
name="checkbox_select_multiple" type="checkbox" value="unknown"><label class="form-check-label"
for="id_checkbox_select_multiple_2">Unknown</label></div>
</div>
<div class="form-text" id="hint_id_checkbox_select_multiple">
help
</div>
</div>
</form>
</form>
5 changes: 4 additions & 1 deletion tests/results/test_grouped_checkboxes_failing.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
required.</strong></p>
</div>
</div>
<div class="form-text" id="hint_id_checkbox_select_multiple">
help
</div>
</div>
</form>
</form>

0 comments on commit 521514e

Please sign in to comment.