[[CakePHP3めも]]

bakeで生成されるContollerのコードでは以下のようになると思います。

     public function add()
     {
         $user = $this->Users->newEntity();
         if ($this->request->is('post')) {
             $user = $this->User->patchEntity($user, $this->request->data);
             if ($this->Users->save($user)) {
                 $this->Flash->success(__('The user has been saved.'));
                 return $this->redirect(['action' => 'index']);
             } else {
                 $this->Flash->error(__('The user could not be saved. Please, try again.'));
             }
         }
         $this->set(compact('user'));
         $this->set('_serialize', ['user']);
     }



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS