If the model that you authenticate against is the Person model, then you should be able to get away with
public function index() {
$this->set('people', $this->Auth->user();
}
Since Auth->user() should return the whole model. Though you might want to double check with a bit of debug (DebugKit, or CakeLog::debug($this->Auth->user()) or errorLog(print_r($this->Auth->user(), true));
Since Auth->user() should return the whole model. Though you might want to double check with a bit of debug (DebugKit, or CakeLog::debug($this->Auth->user()) or errorLog(print_r($this->Auth->user(), true));
Alternatively, there's:
public function index() {
$person = $this->Person->read(null, $this->Auth->user('id'));
$this->set('people', $person);
}
Once small niggle on readability. Setting 'people' implies that there are might be multiple people in the variable. If there's only ever going to be the one person, I would set('person') instead (i.e. $this->set(compact('person'));) , or put the $person into an array, so you can have a foreach in your index (i.e. $this->set('people', array($person)); )
Regards
Once small niggle on readability. Setting 'people' implies that there are might be multiple people in the variable. If there's only ever going to be the one person, I would set('person') instead (i.e. $this->set(compact('person'));) , or put the $person into an array, so you can have a foreach in your index (i.e. $this->set('people', array($person)); )
Regards
Reuben Helms
On Friday, 30 November 2012 08:10:59 UTC+10, Franklin Piercing wrote:
-- On Friday, 30 November 2012 08:10:59 UTC+10, Franklin Piercing wrote:
Hi, this is what i´m trying to do, i have this index.ctp view where i show some information about the logged user (such as name, mail, etc).. but in the Users table there´s a field called info that the user can update, the thing is that, in my index fuction in my Users´s controller i have this
public function index() {
$this->Person->id = $this->Session->read('Auth.User.id ');
$this->set('people', $this->Person->read());
}
it shows the info perfect, so, in my index view i have a little section with a textfield where the user can update this "info" field, so the thing is that i'm trying to create this form in an element and include it into my index view, i have my controller's action called update_info with the logic to do so.. but it doesn´t works, i don´t know why, anybody canhelp me with this or maybe give me ideas about other ways to do it???
thanx a lot!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
No comments:
Post a Comment