Skip to content

Instantly share code, notes, and snippets.

@veganista
Created December 4, 2012 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veganista/4202602 to your computer and use it in GitHub Desktop.
Save veganista/4202602 to your computer and use it in GitHub Desktop.
public function beforeSave(Model $model, array $options = array()){
var_dump($model->data['User']);
//array (size=4)
// 'id' => string '66' (length=2)
// 'first_name' => string 'new first name' (length=14)
// 'last_name' => string 'new last name' (length=13)
// 'email' => string 'liam@email.com' (length=14)
$x = $model->find('first', array('conditions' => array($model->alias . '.' .$model->primaryKey => $model->id), 'contain' => 'User'));
var_dump($x['User']);
//array (size=10)
// 'id' => string '66' (length=2)
// 'first_name' => string 'new first name' (length=14)
// 'last_name' => string 'new last name' (length=13)
// 'email' => string 'liam@email.com' (length=14)
// 'password' => string '*********************************' (length=40)
// 'password_reset_key' => string '' (length=0)
// 'password_reset_expiry' => string '0000-00-00 00:00:00' (length=19)
// 'group_id' => string '2' (length=1)
// 'created' => string '2012-12-03 15:15:18' (length=19)
// 'updated' => string '2012-12-04 11:55:32' (length=19)
die();
return true;
}
var_dump($this->request->data['User']);
//output of var_dump().....
//array (size=4)
// 'id' => string '66' (length=2)
// 'first_name' => string 'new first name' (length=14)
// 'last_name' => string 'new last name' (length=13)
// 'email' => string 'liam@email.com' (length=14)
if ($this->Applicant->saveAssociated($this->request->data, array('deep' => true))) {
$this->Session->setFlash(__('The applicant has been updated'), 'Flash/success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The applicant could not be updated Please, try again'), 'Flash/error');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment