Closed (fixed)
Project:
Drupal core
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
5 Jan 2006 at 10:28 UTC
Updated:
19 Jan 2006 at 11:20 UTC
Unchecked checkboxes get an int value of 0. Due to the wonderfulness that is PHP's extremely weak typing, 0 == a bunch of random stuff... like any non-numeric string. So when we have a checkbox with a #return_value of some non-numeric string the checkbox becomes checked on rendering because 0 == 'that string' is TRUE.
Flipping around the operands of == changes things so the type of the comparison is determined by #return_value rather than what was returned. If #return_value is a string then we get string comparison. PHP knows that 'string' == 0 is FALSE and sanity is restored.
| Comment | File | Size | Author |
|---|---|---|---|
| form.inc.diff | 814 bytes | drumm |
Comments
Comment #1
dries commentedCommitted to HEAD. Thanks.
Comment #2
(not verified) commented