コード例 #1
0
 public function submitLoginForm(AppForm $form)
 {
     $data = $form->getValues();
     $user = $this->getUser();
     try {
         $user->login($data['username'], $data['password']);
         $this->redirect('HomePage:');
     } catch (\Nette\Security\AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
コード例 #2
0
ファイル: HomepagePresenter.php プロジェクト: jff15/travelbot
 /**
  * locationsForm submit handler (trip saving).
  * @param Nette\Application\AppForm
  */
 public function submitLocationsForm(AppForm $form)
 {
     $values = $form->values;
     $service = new TripService($this->entityManager);
     try {
         $trip = $service->buildTrip($values['from'], $values['to'], new TripCurlMapper());
         $service->save($trip);
         $this->flashMessage('Trip successfully saved.');
         $this->redirect('Trip:show', array('id' => $trip->id));
     } catch (InvalidStateException $e) {
         $form->addError('Error occurred while getting directions. Please try again later.');
     }
 }