Tuesday, December 28, 2010

Re: equalTo validation for booleans

On Dec 28, 2010, at 12:05, Jeremy Burns | Class Outfit wrote:

> Solved - this works:
>
> 'rule' => array('equalTo', '1'),
>
> ...oddly enough.

As you found, CakePHP's equalTo method doesn't use the equal-to operator (==) but the identical-to operator (===) which means you're checking not only the value of the variable but also its type. And form field values would tend to come through as strings. So you need to compare them to strings, not Booleans, not integers -- nonintuitive though I admit that is for checkboxes which we naturally think of as Boolean values.


Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: