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.
Once in a life-time, the default #options handling for #type checkboxes and radios is not sufficient. If you have to define one or more option as sub-element manually, you need to start to study Form API internals to get it right.
It doesn't have to be that hard.
Comment | File | Size | Author |
---|---|---|---|
#17 | drupal.form-options.17.patch | 10.83 KB | sun |
#16 | drupal.form-options.16.patch | 10.93 KB | sun |
#13 | drupal.form-options.13.patch | 10.36 KB | sun |
#11 | drupal.form-options.11.patch | 10.36 KB | sun |
#9 | drupal.form-options.9.patch | 9.51 KB | sun |
Comments
Comment #2
sunStupid me. ;)
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedSeems reasonable. Could you elaborate on a use case?
Comment #4
sunThankfully, we have a use-case (and therefore also test case) in core :)
Comment #5
sunAs visible in the patch, this really simplifies setting custom properties for individual radios/checkboxes, as you only have to care for your custom properties, and nothing else.
Comment #6
sunAny feedback?
Comment #7
sunEach time someone tries to add descriptions to radio buttons or checkboxes, he's running into this dilemma. The patch is straightforward, though I can happily add separate tests if absolutely required.
Comment #8
sun#4: drupal.form-options.4.patch queued for re-testing.
Comment #9
sunActually, this functionality is completely untested currently. Therefore, added tests.
Comment #11
sunoh wow -- this clearly shows that we're missing detailed tests for expanded #options. Fixed those test failures.
Comment #12
sunAny feedback? This patch comes with tests now and looks RTBC to me.
Comment #13
sunAdded one more decimal to the default weights.
Comment #14
effulgentsia CreditAttribution: effulgentsia commentedThis really makes a lot of sense. I can't justify escalating it to "major", so it might languish in the queue, and then be denied, but that would be a shame, because it improves DX with no downside that I can see. The minus signs in comment.module are lovely, just lovely.
This was the one line I was concerned with, since it potentially introduces a BC break. But I looked more into it and it doesn't, because form_builder() starts off forcing #processed to FALSE anyway, so this was a pointless line to begin with.
Powered by Dreditor.
Comment #15
sun#13: drupal.form-options.13.patch queued for re-testing.
Comment #16
sunRe-rolled against HEAD.
Comment #17
sunRe-rolled against HEAD.
Comment #18
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.