My model page - athlete.php - has a method getName():
function getName() {
return $this->data['Athlete']['first_name'] . " " . $this->data
['Athlete']['last_name'];
}
I can call this in my controller and debug the name to the debug
output (last line in the method):
function view($id = null) {
$this->Athlete->id = $id;
$this->set('athlete', $this->Athlete->read());
debug($this->Athlete->getName());
}
I am hoping someone can tell me the correct syntax on how to access
this method directly from a view:
<?php debug($athlete->getName()); ?> returns the following error:
Fatal error: Call to a member function getName() on a non-object in C:
\wamp\www\cake\app\views\athletes\view.ctp on line 2
<?php debug($athlete['Athlete']['name']); ?> returns the error I was
expecting, but I thought there was a slight chance the automajic would
kick in:
Notice (8): Undefined index: name [APP\views\athletes\view.ctp, line
2]
So, can someone show me an example of how to access object methods
directly from w/in a view or let me know if I am approaching this the
wrong way?
Thanks in advance,
Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---