/** * Album edit form component factory. * @return mixed */ protected function createComponentAlbumForm() { $form = new AppForm(); $form->addText('artist', 'Artist:')->addRule(Form::FILLED, 'Please enter an artist.'); $form->addText('title', 'Title:')->addRule(Form::FILLED, 'Please enter a title.'); $form->addSubmit('save', 'Save')->setAttribute('class', 'default'); $form->addSubmit('cancel', 'Cancel')->setValidationScope(NULL); $form->onSubmit[] = callback($this, 'albumFormSubmitted'); $form->addProtection('Please submit this form again (security token has expired).'); return $form; }
/** * @return Nette\Application\AppForm */ protected function createComponentLocationsForm() { $form = new AppForm(); $form->addText('from', 'From')->setRequired('Fill the "from" location, please.'); $form->addText('to', 'To')->setRequired('Fill the "to" location, please.'); $form->addRadioList('oneWay', null, array('One way', 'Round trip')); $form->addText('depart', 'Depart'); $form->addText('return', 'Return'); $form->addSelect('travelers', 'How many travelers', array('1 traveler', '2 travelers', '3 travelers', '4 travelers', '5 travelers', '6 travelers', '7 travelers', '8 travelers')); $form->addSelect('cabin', 'Cabin', array('Economy', 'Premium economy', 'Business', 'First')); $form->addSubmit('okSubmit', 'Save trip')->setDisabled(); $form->addSubmit('okFindDirections', 'Find route'); $form->onSubmit[] = array($this, 'submitLocationsForm'); return $form; }
protected function createComponentMyForm() { $form = new AppForm(); $form->addText('name', 'Name'); $form->addSubmit('submit'); $form->onSubmit[] = callback($this, 'submitMyForm'); return $form; }
protected function createComponentRegisterForm() { $form = new AppForm(); $form->addText('login', 'Username'); $form->addPassword('password', 'Password'); $form->addSubmit('submit'); $form->onSubmit[] = callback($this, 'submitRegisterForm'); 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; }
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; }
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; }