/** * edit method * * @return void */ public function edit() { $this->helpers[] = 'Users.UserEditForm'; $this->__prepare(); if (Current::isControlPanel()) { $this->ControlPanelLayout = $this->Components->load('ControlPanel.ControlPanelLayout'); } else { $this->PageLayout = $this->Components->load('Pages.PageLayout'); } if (Hash::get($this->viewVars['user'], 'User.id') !== Current::read('User.id')) { return $this->throwBadRequest(); } if ($this->request->is('put')) { $redirectUrl = Hash::get($this->request->data, '_user.redirect'); if (array_key_exists('cancel', $this->request->data)) { $this->NetCommons->setAppendHtml('<div class="hidden" ng-controller="Users.controller" ' . 'ng-init="showUser(null, ' . Current::read('User.id') . ')"></div>'); return $this->redirect($redirectUrl); } //登録処理 if ($this->User->saveUser($this->request->data, true)) { //正常の場合 $this->NetCommons->setFlashNotification(__d('net_commons', 'Successfully saved.'), array('class' => 'success')); $this->NetCommons->setAppendHtml('<div class="hidden" ng-controller="Users.controller" ' . 'ng-init="showUser(null, ' . Current::read('User.id') . ')"></div>'); return $this->redirect($redirectUrl); } $this->NetCommons->handleValidationError($this->User->validationErrors); $this->request->data = Hash::merge($this->viewVars['user'], $this->request->data); } else { //表示処理 $this->User->languages = $this->viewVars['languages']; $this->request->data = $this->viewVars['user']; $redirectUrl = $this->request->referer(true); } $this->set('userCancel', SiteSettingUtil::read('UserCancel.use_cancel_feature', false)); $this->set('redirectUrl', $redirectUrl); $this->set('activeUserId', Hash::get($this->viewVars['user'], 'User.id')); }