Your Location is: Home > Cakephp

how to access cakephp model value in contoller

From: Singapore View: 3726 ptailor 


I want to mail verify key field value on mail when customer used forgot password option. My query is working perfect. when i debug in view i am able to see filed value but in controller i am not able to access that value.

Here is my controller query.

public function forgot() {
    if ($this->User->validates() ) {
    $auserlogin = $this->User->forgot($this->data['user']['email']);
    $this->set('auserlogin', $auserlogin);
    $message="Someone requested to reset password \n\n";
    $message=$message."Verify Key : ".$auserlogin['0']['user']['verifykey']."\n\n";
    $Email = new CakeEmail();
    $Email->from(array('[email protected]' => 'mail'))
    ->subject('Forgot Password')
    return $this->redirect(array('controller'=>'users','action'=>'password'));

In view part i am able to see query is working via this


but i want to mail this verifykey to user so i used

$message="Verify Key : ".$auserlogin['0']['user']['verifykey']."\n\n";


$this->set('verifykey', $auserlogin['0']['user']['verifykey']);
$message="Verify Key : ".$verifykey."\n\n";

both are not working in mail i am not receiving variable value on mail i received only

Verify Key :

Best answer

Model name should be in capitalised inside controller. $auserlogin['0']['User']['verifykey']

Credit goes newbee-dev