I don't really understand the problem you present.

Either you display a model field as a read-only piece of information
in the view, and then there is no problem with data being updated.

Or you display model data in a form that can be edited, and in case of
for example the boolean you provide a dropdown list or use a radio
button that displays a readable string to the user but holds the raw
data as the value.


On Wed, Aug 26, 2009 at 2:46 PM, ark0n3<nicolabeg...@gmail.com> wrote:
>
> Hi Jon
> 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..
>
>
>
> On 26 Ago, 11:23, Jon Bennett <jmbenn...@gmail.com> wrote:
>> Hi Nicola.
>>
>> > I'm trying to understand if and in which way could be possible to
>> > achieve such a result. Maybe I've explained the wrong way: I need to
>> > format some common fields like boolean value and achieve this adding
>> > an afterFind(results) callback in the app_model.php. I'd like to know
>> > if this is the best way to accomplish this 'cause I noticed that (of
>> > course) it causes problems when trying to edit something: the datas
>> > are formatted as I requested in the app_model but this causes
>> > validation problems (super simple example: boolean humanized as "Yes/
>> > No" and no more as 1/0).
>>
>> I would have thought the only time you need to display 1 or 0 as yes
>> or no is in the view. You're quite right that if you adjust the data
>> in app_model, it will break your DB.
>>
>> I have a Config value set in my bootstrap, and output that. eg:
>>
>> // bootstrap.php
>> Configure::write('yesno', array(0=>'No', 1=>'Yes');
>>
>> // View
>> Configure::read('yesno.'.$row[$modelClass]['field']); // outputs 'Yes'
>> for 1, and 'No' for 0.
>>
>> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to