我正在尝试在这里完成用户认证 cakephp 教程。http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
如果您查看 UsersController 的代码块,它会显示一个编辑操作。他们提供的唯一视图是 add.ctp 所以我试图完成剩余的视图。我已经创建了一个索引,但现在我无法弄清楚编辑视图发生了什么。
当我转到用户/编辑时,我收到以下消息
Error: The requested address '/cake/users/edit' was not found on this server.
我在我的用户文件夹中有一个保存为 edit.ctp 的页面,所以我对收到此消息的原因感到困惑。
顺便说一下,这是UsersController中的编辑功能
public function edit($id = null) {
$this->User->id = $id;
if (!$this->User->exists()) {
throw new NotFoundException(__('Invalid user'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->User->save($this->request->data)) {
$this->Session->setFlash(__('The user has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
} else {
$this->request->data = $this->User->read(null, $id);
unset($this->request->data['User']['password']);
}
}
我只是应该创建另一个视图并将其传递给编辑功能吗?我很困惑为什么我可以通过添加功能添加用户,但我无法编辑自己的密码/用户名/任何用户属性。