Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.0-rc4
Component:
optionwidgets.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Jul 2008 at 13:39 UTC
Updated:
31 Jul 2008 at 04:47 UTC
Comments
Comment #1
yched commentedThat's actually the intended behavior for the on/off widget.
If checked, the 'on' value is saved, if unchecked, the field is considered empty and saves NULL.
Comment #2
paldr commentedI probably did not make myself clear - it is not possible to save any other value except 'on'. The checkbox always remains in 'checked' position.
Comment #3
yched commentedOh, right, that wasn't clear. I can reproduce that.
Sigh. I thought we had fixed that already. Will need to investigate.
Comment #4
yched commentedSeems to be the case also for selects and radios/checkboxes.
Something's wrong in optionwidgets_validate() / optionwidgets_form2data().
This is a recurrent pain, so for now, I'm focusing on a comprehensive test suite for optionwidgets :-)
Comment #5
yched commentedI committed a suite of tests for optionwidgets.
Tests that fail :
- select : unselect all in multiple select doesn't take
- radios/checkboxes : uncheck all checkboxes doesn't take
- on/off checkbox : uncheck doesn't take
(same bug, as seen by the different widget types)
Comment #6
ppatriotis commentedI also encountered this problem when unchecking all of the checkboxes in an OptionWidget. I found that when nothing was selected in the form, the post omitted the field altogether, and I guess the Forms API filled in the values using the original default ones.
My solution was to change the first line in optionwidgets_form2data from
$items = $element['#value'];
to
$items = isset($element['#post'][$field['field_name']]) ? $element['#value'] : array();
I'm not sure if this will work for every situation but it works for my arrangement of OptionWidgets. I hope this helps.
Comment #7
yched commentedIn fact, it appears the correct FAPI #value to use is $element[$field_key]['#value'], rather than $element['#value'] which is wrong when $POST has no data for the field. Fixed now.
While the issue is now fixed, the optionwidgets simpletests still fail at the same spot :-p
Either a bug in DrupalWebTestCase::drupalPost(), or I'm not using it the right way...
Well, marking this issue fixed for now
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.