Re: HABTM and field formatting issue [Need Suggestion]

2009-01-13 Thread Ernesto

strtoupper was just an example.

anyway...

imho even a "simple" format like this should be handled by the model

On 12 Gen, 21:56, Miles J  wrote:
> Minor things like that could also be done in the view :p
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: HABTM and field formatting issue [Need Suggestion]

2009-01-12 Thread Miles J

Minor things like that could also be done in the view :p
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: HABTM and field formatting issue [Need Suggestion]

2009-01-12 Thread Ernesto

ok.

i copied the function found in linked thread and made all format
functions works on flat arrays ($field => $value).

Format is working like a charm.

Thx a lot

On 12 Gen, 09:14, Ernesto  wrote:
> thx!
>
> missed that thread.
>
> On 9 Gen, 17:10, grigri  wrote:
>
>
>
> > The format of the `$results` array in `afterFind` varies, a lot,
> > depending on circumstance.
>
> > Your best bet is to do a debug($results) inside `afterFind` to see
> > exactly what structure the data is in and act accordingly. There was
> > another thread on this recently. Your `afterFind` code must cope with
> > the different array structures.
>
> > Other thread is 
> > here:http://groups.google.com/group/cake-php/browse_thread/thread/32ab9f8b...
>
> > hth
> > grigri
>
> > On Jan 9, 3:21 pm, Ernesto  wrote:
>
> > > Hello.
>
> > > i have 2 models, linked together by a HABTM relationship.
> > > The 2nd model has a function that formats some fields after the data
> > > is loaded.
> > > Why is this function not working if i load data from the HABTM
> > > relationship?
> > > is there any better way to make this work?
>
> > > Here's an example
>
> > > NOTE: this code is for example purpose only. Don't look @ typos :)
>
> > > class Car extends AppModel {
> > >         var $name = "Car";
>
> > >         var $hasAndBelongsToMany = array(
> > >                 "Passenger" => array(
> > >                         "className" => "Passenger"
> > >                 )
> > >         );
>
> > > }
>
> > > class Passenger extends AppModel {
> > >         var $name = "Passenger";
>
> > >         function afterFind($results, $primary = false) {
> > >                 $results["Passenger"]["Name"] = 
> > > strtoupper($results["Passenger"]
> > > ["Name"]);
> > >                 return $results;
> > >         }
>
> > > }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: HABTM and field formatting issue [Need Suggestion]

2009-01-12 Thread Ernesto

thx!

missed that thread.

On 9 Gen, 17:10, grigri  wrote:
> The format of the `$results` array in `afterFind` varies, a lot,
> depending on circumstance.
>
> Your best bet is to do a debug($results) inside `afterFind` to see
> exactly what structure the data is in and act accordingly. There was
> another thread on this recently. Your `afterFind` code must cope with
> the different array structures.
>
> Other thread is 
> here:http://groups.google.com/group/cake-php/browse_thread/thread/32ab9f8b...
>
> hth
> grigri
>
> On Jan 9, 3:21 pm, Ernesto  wrote:
>
>
>
> > Hello.
>
> > i have 2 models, linked together by a HABTM relationship.
> > The 2nd model has a function that formats some fields after the data
> > is loaded.
> > Why is this function not working if i load data from the HABTM
> > relationship?
> > is there any better way to make this work?
>
> > Here's an example
>
> > NOTE: this code is for example purpose only. Don't look @ typos :)
>
> > class Car extends AppModel {
> >         var $name = "Car";
>
> >         var $hasAndBelongsToMany = array(
> >                 "Passenger" => array(
> >                         "className" => "Passenger"
> >                 )
> >         );
>
> > }
>
> > class Passenger extends AppModel {
> >         var $name = "Passenger";
>
> >         function afterFind($results, $primary = false) {
> >                 $results["Passenger"]["Name"] = 
> > strtoupper($results["Passenger"]
> > ["Name"]);
> >                 return $results;
> >         }
>
> > }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: HABTM and field formatting issue [Need Suggestion]

2009-01-09 Thread grigri

The format of the `$results` array in `afterFind` varies, a lot,
depending on circumstance.

Your best bet is to do a debug($results) inside `afterFind` to see
exactly what structure the data is in and act accordingly. There was
another thread on this recently. Your `afterFind` code must cope with
the different array structures.

Other thread is here: 
http://groups.google.com/group/cake-php/browse_thread/thread/32ab9f8baed4a05a/062678e92b080f18

hth
grigri

On Jan 9, 3:21 pm, Ernesto  wrote:
> Hello.
>
> i have 2 models, linked together by a HABTM relationship.
> The 2nd model has a function that formats some fields after the data
> is loaded.
> Why is this function not working if i load data from the HABTM
> relationship?
> is there any better way to make this work?
>
> Here's an example
>
> NOTE: this code is for example purpose only. Don't look @ typos :)
>
> class Car extends AppModel {
>         var $name = "Car";
>
>         var $hasAndBelongsToMany = array(
>                 "Passenger" => array(
>                         "className" => "Passenger"
>                 )
>         );
>
> }
>
> class Passenger extends AppModel {
>         var $name = "Passenger";
>
>         function afterFind($results, $primary = false) {
>                 $results["Passenger"]["Name"] = 
> strtoupper($results["Passenger"]
> ["Name"]);
>                 return $results;
>         }
>
> }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HABTM and field formatting issue [Need Suggestion]

2009-01-09 Thread Ernesto

Hello.

i have 2 models, linked together by a HABTM relationship.
The 2nd model has a function that formats some fields after the data
is loaded.
Why is this function not working if i load data from the HABTM
relationship?
is there any better way to make this work?

Here's an example

NOTE: this code is for example purpose only. Don't look @ typos :)

class Car extends AppModel {
var $name = "Car";

var $hasAndBelongsToMany = array(
"Passenger" => array(
"className" => "Passenger"
)
);
}

class Passenger extends AppModel {
var $name = "Passenger";

function afterFind($results, $primary = false) {
$results["Passenger"]["Name"] = strtoupper($results["Passenger"]
["Name"]);
return $results;
}
}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---