the default value doesn't show correctly for checkbox option widget in forms where the values are text. It always shows as selected.
this is because for a checkbox the default value is either True or False, but the form is setting the default value to
$items['default keys'][0], which is always true if you have 2 different texts for on and off.
this can be fixed by doing #default_value' => $items['default keys'][0] == $on_value
patch attached to do that.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | optionwidgets.module.patch | 966 bytes | kenorb |
| checkbox_defaultvalue.patch | 562 bytes | moggy |
Comments
Comment #1
binford2k commentedpatch also works on 5.x with fuzz
Comment #2
john morahan commentedProblem still exists, patch still applies with a small offset and fixes it.
Comment #3
yched commentedFixed - thanks.
Comment #4
(not verified) commentedComment #5
zmove commentedNot fixed for me, I applied the patch and the checkbox continue to be checked by default. (even with uncheck default value in setting).
I use checkboxes on a nodeprodile node type, maybe it's the cause of the problem... don't know;
Comment #6
kenorb commentedTry attached patch. It should be working fine.
Comment #7
francewhoaThe following solution worked for me without any patching.
Into the help text in the 5.x-1.6 release:
So here's what you would do:
1) Add a Single on/off checkbox integer field.
2) Don't worry about changing the "Label" field since this does not does not have anything to do with what is displayed as the label.
3) Enter the following two values in the Allowed values list:
0|Do not display
1|Display
Now when you go to create content page for you content type you should have a checkbox with a "Display" label.
It works but it's not user friendly. It needs to be simplify.
Thanks to jsenich for this solution.
Comment #8
acrymble commentedthis solved my problem without installing anything.
Thanks
Comment #9
karens commentedThe D5 version is no longer being supported. Sorry.