Add swapLabelAndValue() option to BooleanField - #7773
Open
ERuban wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
A possible follow-up, if there's interest: #6018 also asked for a way to configure this once for the whole backend ("or as an alternative add a setting in the Dashboard/Crud config classes"). This could be a Happy to send that as a separate PR if you think it fits - this one stays field-level only to keep it small. |
ERuban
force-pushed
the
add_boolean_label_swap_option
branch
from
August 3, 2026 20:56
df3f727 to
ae61ae2
Compare
ERuban
force-pushed
the
add_boolean_label_swap_option
branch
from
August 5, 2026 12:26
ae61ae2 to
e772b79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 4.8.0, boolean fields on the detail page swap the usual label <-> value order (#5977). The reasoning is documented in the CSS: the label is usually a medium-long string and the value is always tiny.
This has been a recurring pain point: #6018 (open since 2023,
priority: important, 16 comments) collects several requests and at least three different sets of user-land CSS workarounds. The thread doesn't ask to revert the default — it asks for an opt-in way to restore the regular order ("I am still for having some opt-in possibility for this swap").This PR adds that option, following the style of the existing
renderAsSwitch()/hideValueWhenTrue()options:The default behavior doesn't change. The option defaults to true (current behavior). When set to false, the configurator adds a field-boolean-no-swap CSS class and the existing swap rules are scoped with :not(.field-boolean-no-swap) — so a disabled swap simply renders the field like every other field, with no counter-rules fighting specificity.
Includes tests, documentation and rebuilt assets (only the CSS bundle changed).
Closes #6018