如何将表单中的数据传递给控制器,然后将该数据传递给模型
public function registertest()
{
if (!empty($this->data)) {
var_dump($this->data);
if ($this->data['User']['password'] == $this->Auth->password($this->data['User']['cpassword'])) {
$this->User->create();
if($this->User->save($this->data)) {
$this->Auth->login($this->data);
$this->redirect(array('action' => 'index'));
}
}
}
//$this->render('register');
}
答案 0 :(得分:0)
使用此代码
public function registertest()
{
if ($this->request->is('post')) {
$this->data['User']['password'] == $this->Auth->password($this->data['User']['cpassword']);
$this->User->create();
if($this->User->save($this->request->data['User'])) {
$this->Auth->login($this->request->data['User']);
$msg = '<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong> User Created succeesfully </strong>
</div>';
$this->Session->setFlash($msg);
$this->redirect(array('action' => 'index'));
}
}
}