The values are really only used to trigger different types of validation. Since they don't need to be stored, I can easily adapt to use string values. I think it'd be a good idea to specify in the documentation that you should only use integers OR strings (or that if you mix them, you should avoid using zero as one of the values.
The more I think about it, though, the more I think that comparison should be made more strict. I've seen a few other people reporting running into this issue. On Sep 20, 3:59 am, euromark <[email protected]> wrote: > i find it awkward to mix those values, as well. > you can use integer values as keys and replace them later on with > text. or use strings from the beginning. > > On 20 Sep., 01:34, "[email protected]" > > > > > > > > <[email protected]> wrote: > > I'm running into a weird situation where I have three CakePHP- > > generated radio buttons with values "1", "new" and "0" respectively. > > The issue is that when I select the radio button with value "new", > > both it and the one with value "0" are marked as checked after > > submitting the form. (I confirmed this in the generated HTML source). > > > I did some digging and in cake/libs/view/helpers/form.php, line 1088: > > > if (isset($value) && $optValue == $value) { > > $optionsHere['checked'] = 'checked'; > > > } > > > Since this code will compare "new" to 0, it will convert the string to > > an integer first and since 0 == 0, it will be marked as checked. > > > Now, I rethought my approach and it's fine (probably better?) for me > > to just use the values "current", "new", and "none" for my three radio > > buttons, instead of mixing numbers and a string value. However, I > > wasn't sure if this is a bug that should be reported. > > > Should that comparison in the code above be more strict, e.g. > > $optValue === $value ? > > > Thanks, > > gRegor -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
