Active
Project:
Content Construction Kit (CCK)
Version:
6.x-2.x-dev
Component:
optionwidgets.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Apr 2010 at 19:05 UTC
Updated:
26 Oct 2011 at 05:52 UTC
To re-create this bug:
1. Create a text-field with checkboxes widget.
2. In widget settings: Required: Yes, Number of values: unlimited, Allowed values list: put in a few values
3. Save the widget and then go back, edit the widget again, select some default values.
4. Write a little hook_form_alter to add ['#access'] = FALSE to the field.
5. When trying to save that field, you will get the error: "illegal value".
Expected behavior is that the field is saved with the default value. This bug does not exist for any other widget type as far as I can tell.
Comments
Comment #1
phayes commentedNote that this is a blocker for the follow issue in urlfill: #767060: Hide field breaks checkboxes
Comment #2
jrockowitz commentedI am not familiar enough with the inner workings of CCK to recommend a patch/fix.
I did apply the below work-around.
Comment #3
masondib commentedI'm having a similar issue: getting the "illegal value" error message on a checkboxes, unlimited-value text field with
['#access'] = FALSEset via hook_form_alter.In my case, the field is not required, and no default value is set so the field value should be null, but it looks like somehow it's being set to (integer) 1. Which, in turn, is making text.module trip up on a non-text, non-allowed value. Couldn't trace this back to the source, but hopefully this information will help someone else identify the culprit.
My workaround was to call
unset($field)in hook_form_alter instead of setting #access to FALSE, which seems to be working, but I'm not sure if this is best practice.Comment #4
Chris Gillis commentedI have the same issue. None of my checkboxes are selected, but if I set the field to #access = FALSE, I can no longer submit the form without seeing an Illegal values error. It seems to be getting the integer 1, instead of NULL.
I can confirm that the workaround in #2 works for me.
Comment #5
webadpro commentedI'm having the same problem. Anyone found a fix for this?
Solution #2 fixed it for me also, but this should get fixed.
Comment #6
babbage commentedSame issue. Most frustrating.
Comment #7
djschoone commentedhad same isssue with onoff checkbox
workaround #765962-2: Cannot assign default values to checkboxes when #access is set to FALSE works for me
Comment #8
arhak commentedperhaps wanna check out core's #1114480: expand_checkboxes #default_value when #access=FALSE