With the patch, I can have all the checkboxes toggle on/off based on the checked state of another checkbox.I think it makes sense to support this for checkboxes. For radios, this probably doesn't make much sense.
However, what I really want is to check all the checkboxes when the other checkbox is checked but leave the checkboxes alone when that other checkbox is unchecked. It seems the #state system is unable to do this and we have to do custom javascript for this kind of functionality. Is this correct?
Comment | File | Size | Author |
---|---|---|---|
#8 | checkboxes-states-1032062-8.patch | 532 bytes | star-szr |
#6 | Screen Shot 2012-01-23 at 11.14.53 PM.png | 21.72 KB | ryan.gibson |
#6 | Screen Shot 2012-01-24 at 12.50.52 AM.png | 45.17 KB | ryan.gibson |
#6 | Screen Shot 2012-01-24 at 12.50.57 AM.png | 48.6 KB | ryan.gibson |
#2 | checkboxes-states.patch | 809 bytes | mattyoung |
Comments
Comment #1
BerdirAlways set issue status to needs review when there is a patch.
Comment #2
mattyoung CreditAttribution: mattyoung commentedSimplify a little because
drupal_render()
does this:So we can put NULL in '#states' and that will not be processed.
I use
!empty($elements['#states'])
instead ofisset($elements['#states'])
like the '#ajax' key becuasedrupal_render()
uses!empty()
.Comment #3
kalebheitzman CreditAttribution: kalebheitzman commentedApplied the patch on clean install and the install still works fine. I'm not sure how to actually test the functionality of this patch.
Comment #4
mattyoung CreditAttribution: mattyoung commentedYou won't see anything different with this patch unless you use the '#states' on a "checkboxes" form element like this:
Before the patch, clicking on the "Eat all" checkbox does nothing to the "fruits" checkboxes. With the patch, all the checkboxes in "fruits" follow the check state of "eat_all".
Comment #5
BerdirMoving to the 8.x queue and tagging for possible backport.
Comment #6
ryan.gibson CreditAttribution: ryan.gibson commentedAlright, just going to post my results here - I'm not exactly sure what was trying to be accomplished. But I think I got it.
Pre patch, the select box did not affect the dependee checkboxes. No matter what I did, they remained. (first screenshot).
After applying the patch, the select box did in fact turn the dependee checkboxes on or off accordingly. (screenshots 2 and 3.)
That is all. :)
Comment #7
ryan.gibson CreditAttribution: ryan.gibson commentedSorry I didn't mention before - I tested the above in FF and Webkit browsers.
Comment #8
star-szrReroll for 8.x.
Comment #10
xjmWas a bot issue.
There is now an 8.x branch of the #states exercise module available:
http://drupal.org/project/1269964/git-instructions
Comment #11
dawehnerThis issue seems to be a duplicate of #994360: #states cannot check/uncheck checkboxes elements. The other one is older, has more comments and even fixes radios.
Comment #12
Garrett Albright CreditAttribution: Garrett Albright commentedI concur that this is a dupe. Closing.