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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, drupal.form-options.0.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
2.97 KB

Stupid me. ;)

moshe weitzman’s picture

Seems reasonable. Could you elaborate on a use case?

sun’s picture

FileSize
4.53 KB

Thankfully, we have a use-case (and therefore also test case) in core :)

sun’s picture

As 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.

sun’s picture

Any feedback?

sun’s picture

Each 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.

sun’s picture

#4: drupal.form-options.4.patch queued for re-testing.

sun’s picture

FileSize
9.51 KB

Actually, this functionality is completely untested currently. Therefore, added tests.

Status: Needs review » Needs work

The last submitted patch, drupal.form-options.9.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
10.36 KB

oh wow -- this clearly shows that we're missing detailed tests for expanded #options. Fixed those test failures.

sun’s picture

Any feedback? This patch comes with tests now and looks RTBC to me.

sun’s picture

FileSize
10.36 KB

Added one more decimal to the default weights.

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community

This 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.

+++ includes/form.inc	9 Oct 2010 16:55:17 -0000
@@ -2824,18 +2830,23 @@ function form_process_checkboxes($elemen
-          '#processed' => TRUE,

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.

sun’s picture

#13: drupal.form-options.13.patch queued for re-testing.

sun’s picture

FileSize
10.93 KB

Re-rolled against HEAD.

sun’s picture

FileSize
10.83 KB

Re-rolled against HEAD.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -DX (Developer Experience)

Automatically closed -- issue fixed for 2 weeks with no activity.