Skip to content

renderers: honor show_label and label_class on checkbox labels - #891

Merged
dyve merged 2 commits into
mainfrom
fix/127-checkbox-label
Sep 21, 2026
Merged

dyve merged 2 commits into
mainfrom
fix/127-checkbox-label

Conversation

@dyve

@dyve dyve commented Sep 20, 2026

Copy link
Copy Markdown
Member

add_checkbox_label hardcoded label_class="form-check-label" and never looked at show_label, so both parameters were silently dropped for checkboxes while working everywhere else. In horizontal layout that left a visible label next to the checkbox even though the outer label had already been reduced to sr-only, which is exactly the markup in #127.

A new get_checkbox_label_class follows the same rules as get_label_class: show_label=False and show_label='sr-only' add sr-only, and show_label='skip' omits the label entirely, matching what get_label already does for other fields. label_class extends form-check-label rather than replacing it, because that class is structural Bootstrap markup that the checkbox needs to lay out at all. That is the one judgement call here and the place to push back: for non-checkbox fields label_class replaces, so this is deliberately not symmetrical.

Rendered output changes only for callers that pass show_label or label_class on a checkbox.

Fixes #127

🤖 Generated with Claude Code

@coveralls

coveralls commented Sep 20, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 86.521% (+0.1%) from 86.385% — fix/127-checkbox-label into main

@dyve
dyve force-pushed the fix/127-checkbox-label branch from 486935d to 5f0e1c9 Compare September 20, 2026 14:43
add_checkbox_label hardcoded label_class="form-check-label" and never
looked at show_label, so both parameters were silently dropped for
checkboxes while working everywhere else. In horizontal layout that left a
visible label next to the checkbox even though the outer label had already
been reduced to sr-only.

show_label now follows the same rules as get_label_class: False and
'sr-only' add sr-only, 'skip' omits the label. label_class extends
form-check-label rather than replacing it, because that class is
structural Bootstrap markup.

Rendered output only changes for callers that pass show_label or
label_class on a checkbox.

Fixes #127

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dyve
dyve force-pushed the fix/127-checkbox-label branch from 5f0e1c9 to 414f2ab Compare September 20, 2026 14:45
@dyve dyve changed the title renderers: honour show_label and label_class on checkbox labels renderers: honor show_label and label_class on checkbox labels Sep 20, 2026
@dyve
dyve merged commit caddc23 into main Sep 21, 2026
1 check passed
@dyve
dyve deleted the fix/127-checkbox-label branch September 21, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bootstrap_field show_label not honoured for checkboxes

2 participants