public function submitRegisterForm(AppForm $form) { $data = $form->getValues(); AuthService::register($data['login'], $data['password']); $this->flashMessage('Successfully registered'); $this->redirect('default'); }
protected function createComponentMyForm() { $form = new AppForm(); $form->addText('name', 'Name'); $form->addSubmit('submit'); $form->onSubmit[] = callback($this, 'submitMyForm'); return $form; }
/** * 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.'); } }
public function render() { // render("begin") or render("end") $args = func_get_args(); if ($args) { parent::render($args[0]); return; } $this->getTemplate()->form = $this; $this->getTemplate()->render(); }
protected function createComponentAddTagForm() { $form = new AppForm(); $form->addText("name", "Name", 40, 50); $form->addSubmit("s", "Add"); $presenter = $this; $form->onSubmit[] = function ($form) use($presenter) { $name = $form->values["name"]; $tag = new Tag(); $tag->name = $name; $tag->url = String::webalize($name); try { $tag->save(); $presenter->flashMessage("Tag was added!"); $presenter->redirect("default"); } catch (\ModelException $e) { $tag->addErrorsToForm($form); } }; return $form; }
/** * Login form component factory. * @return mixed */ protected function createComponentLoginForm() { $form = new AppForm(); $form->addText('username', 'Username:'******'Please provide a username.'); $form->addPassword('password', 'Password:'******'Please provide a password.'); $form->addSubmit('login', 'Login'); $form->addProtection('Please submit this form again (security token has expired).'); $form->onSubmit[] = callback($this, 'loginFormSubmitted'); return $form; }
/** * Login form component factory. * @return mixed */ protected function createComponentLoginForm() { $form = new AppForm(); $form->addText('username', 'Username:'******'Please provide a username.'); $form->addPassword('password', 'Password:'******'Please provide a password.'); $form->addCheckbox('remember', 'Remember me on this computer'); $form->addSubmit('login', 'Login'); $form->onSubmit[] = callback($this, 'loginFormSubmitted'); return $form; }
private function createBaseForm($name) { $f = new AppForm($this, $name); $f->addProtection(); return $f; }
/** * Album delete form component factory. * @return mixed */ protected function createComponentDeleteForm() { $form = new AppForm(); $form->addSubmit('cancel', 'Cancel'); $form->addSubmit('delete', 'Delete')->setAttribute('class', 'default'); $form->onSubmit[] = callback($this, 'deleteFormSubmitted'); $form->addProtection('Please submit this form again (security token has expired).'); return $form; }
/** * Return element prototype of nested Form * @return \Nette\Web\Html */ public function getFormElementPrototype() { return $this->form->getElementPrototype(); }
protected function createComponentAddCommentForm() { $form = new AppForm(); $form->addTextArea("text", "Text", 40, 10); $form->addText("name", "Author", 40); $form->addText("mail", "E-mail", 40); $form->addSubmit("s", "Send comment"); $presenter = $this; $form->onSubmit[] = function ($form) use($presenter) { try { $values = $form->values; $values["page"] = $presenter->getParam("id"); $comment = Comment::create($values); $comment->save(); $presenter->flashMessage("Comment added!"); $presenter->redirect("this"); } catch (ModelException $e) { $comment->addErrorsToForm($form); } }; return $form; }
public function __construct(Nette\IComponentContainer $parent = NULL, $name = NULL) { parent::__construct($parent, $name); $this->buildForm(); }