Example #1
0
 public function save(Nette\Application\UI\Form $form)
 {
     $flag = $this->context->createServiceFlags();
     try {
         $vars = $form->getValues();
         if ($vars['www'] !== '') {
             $form->addError('Are you a spam robot, right?');
             throw new AuthorizationException('Are you a spam robot, right?');
         }
         unset($vars['www']);
         $flag->flag = $vars;
         $flag->save();
         $cache = new Nette\Caching\Cache($this->context->cacheStorage);
         $cache->clean(array('flags', 'flag'));
         $this->flashMessage('Děkujeme! Váš podnět k aktualizaci zpracujeme. Peknyden.cz.', 'success');
         $this->hide = true;
     } catch (AuthorizationException $e) {
         $this->flashMessage($e->getMessage(), 'error');
     } catch (Exception $e) {
         $this->flashMessage('There is error during saving flag! We know about this. Try it later, please.', 'error');
     }
     if ($this->parent->isAjax()) {
         $this->redrawControl('form');
     }
 }