AR tinyint as boolean

I must be missing something obvious, but is there a way to use a tinyint field as boolean without explicitly defining it as tinyint(1)? I'm guessing I'll need to do the conversion in the afterFind and beforeSave methods? Or is there an easier way?

You mainly need to validate user input to make sure the input is the range of boolean values, something like the following:



array('xyz', 'in', 'range'=>array(0,1))


But for working with checkboxes etc. I guess it's easier to convert them to boolean values? Or what do you suggest for that?

The rule is meant to be used with checkbox. ;) You don’t need explicit conversion because true/false is the same as 1/0 unless you do strict type comparison.

Thanks, it works fine. I thought I read somewhere the checkboxes needed true/false so I assumed strict checking. Should’ve just tested it instead :)