The data is just a straight draw from the database such as a
controller

                $data=$this->Contact->findAll(
                                null,
                                
array('id','uid','fullName','email','admin','active'),
                                $order,
                                $this->params['form']['limit'],
                                $page);

                $dataR = Set::extract($data, "{n}.Contact");

                $this->set('data',$dataR);

admin and active are boolean true/false

Then JSON encoding in the view
e($javascript-
>object($data,true,'MJ.data=',';',array('fullName','email')));

Since mysql doesn't have a real boolean datatype, admin and active are
treated as strings as they get sucked from the database. I can either
cast them as booleans prior to the JSON encoding so it knows to deal
with them as booleans, or set the parameters on the encoding function.
Either way, I have to specify how to treat individual fields. This
seems counter to cake's philosophy of convention over configuration.

Maybe the encoder should have a parameter for values that do not get
quoted (similar to the existing keys one), and have true, false, null,
etc. not quoted as the default.


On Aug 13, 5:11 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> As you said, the Javascript helper object() function already correctly
> deals with booleans.  So the problem is just with your data - so what
> is your data?  Do you mean because the data from the database is
> actually a string based int (ie '0' or '1'), and you want this to be a
> boolean before going into the Javascript object() function?  Or is
> your data from the view, and is 'true' and 'false' ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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