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.
After #367595: Translatable fields, list fields cause WSOD when a bundle with the field is edited.
It could be options widget. Maybe plach can illuminate.
Comment | File | Size | Author |
---|---|---|---|
#15 | options-557924-14.patch | 9.22 KB | bjaspan |
#11 | options-557924-11.patch | 9.22 KB | bjaspan |
#9 | options-557924-9.patch | 8.95 KB | bjaspan |
#2 | options-557924-2.patch | 1.14 KB | plach |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedplach:
I added a list field / select widget and it works. If I change that select widget to an checkbox/radio widget, WSOD.
Comment #2
plachThis issue was partially fixed by #557932: Taxonomy term field autocomplete widgets never validate, always lose values.. The current patch should fix a broken behavior in options.module which should not derive from the refactoring introduced by #367595: Translatable fields. A field api guru's feedback is badly needed here.
Edit: If the remaining issue is actually an options.module issue please change the title and remove the tag translatable fields.
Comment #4
plachHead was broken. Re-testing.
Comment #5
bjaspan CreditAttribution: bjaspan commentedI'm not a wizard on the FAPI-related parts of Field API. But I tried a List field (not numeric or text, just list) on a node type, with (single and unlimited values) x (checkboxes/radios and select list). I got no WSODs, but I do get a warning on single-value radio buttons:
This does look like the problem fixed by the first part of the patch. However, the second part of the patch does this:
and $value becomes #default_value in the FAPI element of type checkboxes or radios. I do not think part of the patch is right. If $multiple is TRUE, the form element is 'checkboxes', and form_process_checkboxes() does:
So $value[$key] = 1 looks right; #default_value should be an array keyed by box keys to be enabled. If $multiple is FALSE, the form element is 'radios', and form_process_radios() does:
so #default_value should be a single value, the key of the radio button to enable. In neither of these cases should #default_value be an array of values of box keys to be enabled.
But I am not a Field API FAPI wizard.
Comment #6
plachI tested the patch on a fresh install with all the core fields having the checkboxes/radio buttons widget and I can confirm I experience an improved behavior with the patch applied. Without it I get an Apache crash (!) on initially saving the field settings and the following errors after submitting the field configuration form:
Moreover I get the following error after creating a node:
The patch seems to fix all the errors. Changing to CNR again because we need more eyes on this.
Comment #7
plachComment #8
bjaspan CreditAttribution: bjaspan commentedGiven the subtleties and the fact that plach and I are seeing different behavior, I think this is a great case for some unit tests. I'll see if I can do that on the plane to France today.
Comment #9
bjaspan CreditAttribution: bjaspan commentedI finally made progress on this! I've implemented basic unit tests for the options widgets, and I must say I think they are pretty sweet. I'm really happy to have them. Here is what I've learned:
1. The patch in #2 is right. There is no WSOD any more, but without the patch, checkboxes do not get initialized properly when there is existig data; with the patch, checkboxes do get initialized. So, the patch fixes a bug.
2. The new tests seem to reveal that something is wrong with radio buttons. When there is no existing data, they cause PHP warnings. The problem is that when theme_radio() is called, $variables['element']['#value'] is an array, but the theme function passes it to check_plain() which of course expects a string.
So, the patch from #2 is right and is included in this new patch, but the tests still fail because of the radio button issue.
Note that this patch creates a new file, options.test.
Comment #11
bjaspan CreditAttribution: bjaspan commentedThe problem described in #9 item 2 is that an options_buttons element's #default_value for radio buttons is correctly initialized to an integer if there is a default value, but is left as an array() if there is no default value because the loop that would change $value from its initial value of array() to an integer never runs. This version of the patch fixes that. I am not 100% sure that setting #default_value to the empty string if there is no default is "right" but it does seem to work, as proved by the tests.
Comment #12
bjaspan CreditAttribution: bjaspan commentedThis is no longer about translatable fields.
Comment #14
andypostReady to review, from duplicate #595702: Warnings when adding taxonomy term-field with checkboxes wodget
Comment #15
bjaspan CreditAttribution: bjaspan commentedRe-roll.
Comment #16
andypostTested this deeply. #11 exactly describes (checkboxes is array, radios is integer) - so tests cover both cases
Comment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!