Well I guess your way is the more elegant one. :-)

Been away from programming a couple of years.

Thank you very much.

/Anders

On Oct 3, 10:30 am, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> Over-engineer much? ;-)
>
> echo $model['boolField'] ? 'Yes' : 'No';
>
> On 3 Oct 2008, at 17:08, Kanten wrote:
>
>
>
> > Hi,
>
> > I have a MySQL table with lots of boolean fields (BOOL) and when
> > viewing these in my view I would like to output "Yes" or "No" instead
> > of "1" or "0".
>
> > I have experimented a bit with doing stuff like this in my controller:
>
> >            foreach (array_keys($data['BrugadaProfile']) as $key):
> >                    if ($data['BrugadaProfile'][$key] == 1 && ! 
> > strpbrk($key, 'id'))
> > { //Avoid recoding foreign key fields
> >                            $data['BrugadaProfile'][$key] = 'Yes';
> >                    } elseif ($data['BrugadaProfile'][$key] == 0 && ! 
> > strpbrk($key,
> > 'id')) {
> >                            $data['BrugadaProfile'][$key] = 'No';
> >                    }
> >            endforeach;
>
> > But this approach is obviously very error prone and I think the best
> > way to go about it, is to somehow access the field type to check if
> > its a boolean field and then recode it.
> > How can this be done?
>
> > /Anders
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to