我有一个视图,其中有两个表单。一个用于登录,另一个用于注册。对于注册操作,我使用了操作
Users/add
我在我的
login.ctp
喜欢
<?= $this->Form->create($user, ['url' => ['action' => 'add']]); ?>
在add action I中编写的代码
public function add()
{
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->getData());
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'login']);
}else{
$this->Flash->error(__('The user could not be saved. Please, try again.'));
return $this->redirect(['action' => 'login']);
}
}
$this->set(compact('user'));
}
现在,如果我犯了任何验证错误,例如密码匹配验证错误,则此错误不会显示在字段下
password
. 但我可以从add中看到它。ctp。
如何将此验证错误消息从添加操作发送到登录操作?