/**
  * 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;
 }
Beispiel #2
0
 /**
  * @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;
 }
Beispiel #3
0
 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;
 }
Beispiel #5
0
 /**
  * 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;
 }
Beispiel #6
0
 /**
  * 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;
 }
Beispiel #7
0
 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;
 }
Beispiel #8
0
 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;
 }