public function registerAction() { $user = new User(); $form = new UserForm($user); $form->setFieldsMap(array('PlainPassword' => array(new Limit(null, 255), new NotBlank(), new Password()))); if ($this->request->isPostMethod()) { $form->handleRequest($this->request); if ($form->isValid()) { $plainPassword = $user->getPlainPassword(); DB::create($user, $errors); if ($this->registry->auth->login($user->Email, $plainPassword)) { FormMessage::sendMessage(FormMessage::SUCCESS, 'Your account is successfully registered.'); $this->redirectUrl(BASE_URL . '/profile'); } } } return array('title' => 'Create Account', 'form' => $form); }
public function editEduAction() { $id = $this->request->getRouteValue('id'); /** @var Education $record */ $record = DB::getObjectByID('Education', $id); $form = $this->getEducationForm($record); if ($this->request->isPostMethod()) { $form->handleRequest($this->request); if ($form->isValid()) { // update record if (!DB::update($record, $errors)) { throw new Exception($errors['message'][2], (int) $errors['code']); } FormMessage::sendMessage(FormMessage::SUCCESS, 'Your institution is successfully saved.'); if ($this->request->getValue('SaveAndExit')) { $this->redirectUrl(BASE_URL . '/profile'); } } else { FormMessage::sendMessage(FormMessage::ERROR, 'Sorry, saving went wrong... Try again.'); } } return array('title' => 'Edit Institution', 'form' => $form); }