Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would like to display a field when certain checkbox is unchecked/off, unfortunately js is not handling that case. I only works for reverse case: hide a field when checkbox is checked/on.
Comment | File | Size | Author |
---|---|---|---|
#1 | conditional_fields_unchecked.patch | 1.06 KB | DevElCuy |
Comments
Comment #1
DevElCuy CreditAttribution: DevElCuy commentedValidation filter was changed, it now looks for all checkboxes in field and returns object value if checked or ""(empty string) if unchecked.
Blessings!
Comment #2
peterpoe CreditAttribution: peterpoe commentedI'm sorry, but I don't understand what kind of functionality you are proposing.
Comment #3
peterpoe CreditAttribution: peterpoe commentedComment #4
DevElCuy CreditAttribution: DevElCuy commentedI have an integer field with 2 posible values: 0 and 1. It is also configured to work as checkbox, so, when checked it returns 1 and when unchecked it returns 0. Problem is that I need to display a conditional field when checkbox is unchecked, I mean, when it returns 0. Current javascript handling of unchecked checkbox does not returns 0, it returns null instead and does not triggers the displaying of conditional fields.
In short, when conditional fields is configured to display A field when B field es unchecked. B field is never displayed.
Blessings!
Comment #5
jim0203 CreditAttribution: jim0203 commentedI've got the same problem, in D6. If a single checkbox is checked, and a field is set to display when that checkbox is checked, it displays. But if the field is set to display when the checkbox is unchecked, it never displays.
Comment #6
peterpoe CreditAttribution: peterpoe commentedThis can't be fixed for now: since the "off" value of the checkbox field is not present in the output, Conditional Fields can't check its settings against it. If we don't want to insert nasty hacks in the javascript, like checking if there is only one checkbox in the field – and we don't – the only way to fix this issue properly is to add a "negate" condition in the controlled field settings.
Since this would be an entirely new feature, it is postponed after 1.0 release.
Comment #7
peterpoe CreditAttribution: peterpoe commentedThis would be a nice to have, but we don't have a db row and a UI for per field settings.
I created a new issue that needs to be solved before this feature can be implemented: #718138: Per field settings (instead of per content type)
Comment #8
locomo CreditAttribution: locomo commentedthis would be a very helpful feature
Comment #9
YK85 CreditAttribution: YK85 commented+1 subscribing
Comment #10
mautumn CreditAttribution: mautumn commentedCreated a new issue about this #866914: Unsupported single on/off checkbox widget field to hopefully better highlight this issue.
Comment #11
Swipular CreditAttribution: Swipular commented+1 subscribing
Comment #12
bwinett CreditAttribution: bwinett commented+1 subscribing
Comment #13
mordek CreditAttribution: mordek commented+1 subscribing
Comment #14
peterpoe CreditAttribution: peterpoe as a volunteer commented