Setup: The webform contains a select component and one of the options in the list is a key of 0 (zero).
Symptom: When the webform is saved to the database and then later edited (either by resuming a draft edit or by editing a submitted form), and when there is no selection for the component, the option with a key of 0 will become selected (even though the user did no such thing).
Reason: A "no value selected" value is stored in the database as an empty string. When an empty string is used as the '#default_value' for a radios form element and one of the options has a 0, that option is selected.
Solution: When setting the '#default_value', convert any empty strings to NULL.
Fixed and committed to 7.x-4.x and 8.x
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | webform-select_defaults_empty_0_key-2286429-1.patch | 1.17 KB | danchadwick |
Comments
Comment #2
danchadwick commentedComment #4
danchadwick commented