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.

CommentFileSizeAuthor
form.inc.diff814 bytesdrumm

Comments

dries’s picture

Status: Needs review » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)