You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to save data using save() in cakkephp 2.4.6 code as below:
Controller:
public function add() {
if ($this->request->is('post')) {
$this->User->create();
debug($this->request->data);
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('New user has been saved'));
//return $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(
__('User could not be saved. Please, try again.')
);
}
}
Model:
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new SimplePasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
return true;
}
This is not a help forum. The ticket tracker is reserved for possible
bugs and feature enhancements to the CakePHP framework. If you are
looking for help on how to implement a feature or to better understand
how to use the framework correctly, please visit one of the following:
i'm trying to save data using save() in cakkephp 2.4.6 code as below:
Controller:
Model:
debug:
table:
Swing Error:
Error: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
tbcs
.users
, CONSTRAINTrole_fk
FOREIGN KEY (role
) REFERENCESroles
(id
) ON UPDATE CASCADE)SQL Query: INSERT INTO
tbcs
.users
(status
) VALUES (1)The text was updated successfully, but these errors were encountered: