You can try creating a couple of methods in your model. One afterFind, and another beforeSave.
You can convert the data however you want in the afterFind, and then convert it back in the beforeSave so that it doesn't mess up your validation and save methods. But you're going to run into other problems with this method as well. The form helper might;' have some issues with the newly formatted data, and not knowing exactly what to do with it. Your best bet is to convert the data how you want right before viewing. It's not the easiest to edit a lot of files, but it will save you headache in the long run. Also... to convert a 0/1 to a No/Yes, you can use the built in Set::enum($select, $list = null) method, leaving the $list var empty will auto populate it with a yes/no array. echo Set::enum($data['boolean_field']) will output "yes" or "no" depending on value. Wrap that in a ucfirst or ucwords to get "Yes" "No", done. On Aug 26, 3:52 pm, ark0n3 <nicolabeg...@gmail.com> wrote: > That's a good starting point but there's need to change every > interested line in the views, while I'd like to obtain an automatic > and centralized solution i.e. if I write a new page there should be no > need to remember that "work-around" > > On 26 Ago, 15:42, Jon Bennett <jmbenn...@gmail.com> wrote: > > > > > Hi Nicola, > > > > thanks for your kind reply but that's just what I'd avoid: I'm trying > > > to accomplish an automatic way to achieve that result, I know it's not > > > right to use a model function and I asked for an MVC and non- > > > validation-breaking way.. > > > Another way would be to create a helper. > > > How about this helper:http://pastie.org/595351 > > > // use it like so > > $data = array('Model'=>array('status'=>1)); > > echo $dataConverter->nice('Model.status', 'onoff', $data); > > > IMHO the thing to remember is that you only adjust the data for > > presentation only, hence it's done in either the view or the > > controller. > > > hth > > > jon > > > -- > > > jon bennett > > w:http://www.jben.net/ > > iChat (AIM): jbendotnet Skype: jon-bennett --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---