<form id="RecipeEditForm" method="post" action="/recipes/edit/5">
我需要从表单操作中删除/ 5,该怎么办。 我正在使用Cakephp 3。
答案 0 :(得分:0)
例如,如何使用户仅编辑自己的用户帐户而无需在url中传递id。
public function edit()
{
$user = $this->Users->find()
->where(['id' => $this->Auth->user('id')])
->firstOrFail();
if ($this->request->is(['patch', 'post', 'put'])) {
$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' => 'index']);
}
$this->Flash->error(__('The user could not be saved. Please, try again.'));
}
$this->set(compact('user'));
}