]['red'])) {
> $color = $this->data['Apple']['color'];
> }
> return $colour == 'red';
>
> }
>
> -Mark
>
> On May 23, 9:59 am, jakobjp wrote:
>
> > I've read a few discussions about CakePHP returning objects vs.
lor = $this->data['Apple']['color'];
> }
> return $colour == 'red';
>
> }
>
> -Mark
>
> On May 23, 9:59 am, jakobjp wrote:
>
>
>
> > I've read a few discussions about CakePHP returning objects vs.
> > arrays, a
isRed method could look like
function isRed($color = null) {
if (!$color && isset($this->data['Apple']['red'])) {
$color = $this->data['Apple']['color'];
}
return $colour == 'red';
}
-Mark
On May 23, 9:59 am, jakobjp wrote:
The code above is for a Model but if you want presentational (in the
view) code, maybe consider creating an AppleHelper with that type of
logic instead.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
You could still have the isRed() function in your model.
class Apple extends AppModel {
function isRed($color = null){
if($color == 'red'){
return true;
}
return false;
}
}
So If you're working in your controller:
$apple = $this->Apple->r
For the given example, it looks to me like you'd do this in the view:
if ($data['Apple']['color'] == 'red')
On Sat, May 23, 2009 at 9:59 AM, jakobjp wrote:
>
> I've read a few discussions about CakePHP returning objects vs.
> arrays, and this i
I've read a few discussions about CakePHP returning objects vs.
arrays, and this is NOT intended to be such. I just have a question,
related to it:
I used to have (i.e. "before CakePHP") objects like this:
class Apple {
var $color;
var $sweet;
function __construct($id =