public function handleSave(Form $form) { if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) { try { $this->mapper->entityManager->getRepository(get_class($form->data))->save($form->data); } catch (\Exception $e) { $ok = true; if (is_array($this->onCatchError) || $this->onCatchError instanceof \Traversable) { foreach ($this->onCatchError as $handler) { if (\Nette\Callback::create($handler)->invokeArgs(array($form, $e))) { $ok = false; break; } } } elseif ($this->onCatchError !== NULL) { $class = get_class($this); throw new \Nette\UnexpectedValueException("Property {$class}::onCatchError must be array or NULL, " . gettype($this->onCatchError) . " given."); } if ($ok) { throw $e; } } } }
public function actionFormSuccess(VForm $form) { $this->invalidateControl('actionForm'); if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) { $this->id = NULL; $this->formName = NULL; if (!$this->presenter->isAjax()) { $this->redirect('this', array('formName' => NULL, 'id' => NULL, 'mode' => NULL)); } $this->invalidateControl('table'); if ($this->mode === $this::MODE_PLACE) { $this->invalidateControl('navbarFormContainer'); $this->invalidateControl('actionFormContainer'); } $this->presenter->payload->url = $this->link('this', array('formName' => NULL, 'id' => NULL, 'mode' => NULL)); } }
public function formCreateSuccess(\Venne\Forms\Form $form) { if ($form->hasSaveButton() && $form->isSubmitted() === $form->getSaveButton()) { if (!$this->presenter->isAjax()) { $this->redirect('create!', array('createForm' => NULL)); } $this->getPresenter()->invalidateControl('content'); $this->presenter->payload->url = $this->link('create!', array('createForm' => NULL)); $this->createForm = NULL; $this->handleCreate(); } else { $this->invalidateControl('createForm'); } }