/** form for sending message
  * 
  * @return \Nette\Application\UI\Form
  */
 public function createComponentSendMessageForm()
 {
     $form = new Form();
     $form->addText('email', 'Váš email')->addRule(Form::EMAIL, 'Email není platný')->addRule(Form::FILLED, 'Musíte zadat svůj email.');
     $form->addTextArea('text', 'Váš vzkaz')->addRule(Form::FILLED, 'Nelze odeslat prázdnou zprávu')->setAttribute('placeholder', 'Váš vzkaz pro nás.');
     $form->addAntispam('kontrolni', 'Následující políčko vymažte!', 'Jsi spamovací robot?!');
     $form->addSubmit('send', 'Odeslat');
     $form->getElementPrototype()->class('ajax');
     $form->onSuccess[] = $this->sendMessageFormSubmitted;
     return $form;
 }
Esempio n. 2
0
 /** form for editing item 
  * 
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentEditItemForm()
 {
     $form = new Form();
     //$userPairs = $this->userRepository->findAll()->fetchPairs('id', 'name');
     if ($this->pageConfig) {
         /** for each item from configuration for this page create form item
          * 
          */
         foreach ($this->pageConfig["form"] as $item => $params) {
             $formItem = NULL;
             switch ($params["type"]) {
                 case "calendar":
                     //$formItem = $form->addDate($item, $params['text'], Vodacek\Forms\Controls\DateInput::TYPE_DATE);
                     //$formItem = $form->addText($item, $params['text'], 40, 100);
                     $formItem = $form->addDatePicker($item, $params['text']);
                     /** check for minimal date */
                     $min = new DateTime('-100 years 00:00');
                     $max = new DateTime('+100 years 00:00');
                     if (isset($params["min"])) {
                         switch ($params["min"]) {
                             case 'today':
                                 $min = new DateTime('-0 days 00:00');
                                 break;
                             default:
                                 $min = new DateTime($params["min"] . ' 00:00');
                                 break;
                         }
                     }
                     /** check for maximal date */
                     if (isset($params["max"])) {
                         switch ($params["max"]) {
                             case 'today':
                                 $max = new DateTime('+0 days 00:00');
                                 break;
                             default:
                                 $max = new DateTime($params["max"] . ' 00:00');
                                 break;
                         }
                     }
                     $formItem->setAttribute('min', $min->format('Y-m-d'))->setAttribute('max', $max->format('Y-m-d'));
                     break;
                 case "shortText":
                     $formItem = $form->addText($item, $params['text'], 40, 100);
                     break;
                 case "longText":
                     $formItem = $form->addTextArea($item, $params['text'], 40, 5);
                     break;
                 case "location":
                     $formItem = $form->addTextArea($item, $params['text'], 40, 3);
                     break;
                 case "select":
                     $formItem = $form->addSelect($item, $params['text'])->setItems($params["options"])->setPrompt('Vyberte');
                     /** set default value for select if any */
                     if (isset($params["defaultValue"])) {
                         $formItem->setDefaultValue($params["defaultValue"]);
                     }
                     break;
             }
             /** if it is mandatory set rule */
             if (isset($params["mandatory"]) && $params["mandatory"]) {
                 $formItem->addRule(Form::FILLED, 'Je nutné vyplnit "' . $params['text'] . '".');
             }
             /** if it has a hint, show it */
             if (isset($params["hint"])) {
                 $formItem->setOption('description', $params["hint"]);
             }
             /** set actual value if any */
             if (isset($this->editingItem->{$item})) {
                 if ($params["type"] == 'calendar') {
                     //$formItem->setDefaultValue();
                     if (gettype($this->editingItem->{$item}) == 'object') {
                         $this->editingItem->{$item} = $this->editingItem->{$item}->date;
                     }
                 }
                 $formItem->setDefaultValue($this->unescapeTags($this->editingItem->{$item}));
             }
         }
     }
     if (!empty($this->pageConfig['settings']['sendEmail'])) {
         $text = $this->adminEdit ? 'Email' : 'Váš email';
         $form->addText('email', $text, 40, 100)->setDefaultValue($this->editingRow->authorEmail)->setDisabled(TRUE);
     }
     $form->addSelect('delete', 'Chcete tento záznam smazat?')->setItems(array('Ne', 'ANO'));
     $form->addAntispam('kontrolni', 'Následující políčko vymažte!', 'Jsi spamovací robot?!');
     $form->addSubmit('save', 'Uložit');
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'div';
     $renderer->wrappers['pair']['container'] = 'dl';
     $renderer->wrappers['label']['container'] = 'dt';
     $renderer->wrappers['control']['container'] = 'dd';
     $form->getElementPrototype()->class('ajax');
     $form->onSuccess[] = $this->editItemFormSubmitted;
     return $form;
 }
Esempio n. 3
0
 public function createComponentFeedbackWebForm()
 {
     $form = new Form();
     $form->addAntispam();
     $form->addText('name', 'Kontakt:', '', 256);
     $form->addTextArea('note', 'Co se pokazilo? ')->addRule(Form::FILLED, 'Zadejte prosím, co se pokazilo.');
     $form->addSubmit('submit', 'Odeslat');
     $form->onSuccess[] = callback($this, 'processFeedbackWebForm');
     return $form;
 }
 /**
  * Form for updating password when you forgot it
  *
  * @return Form
  */
 protected function createComponentUpdateForm()
 {
     $form = new Form();
     $form->addProtection('Vypršel časový limit, odešlete formulář znovu');
     $form->addAntispam();
     $form->addHidden('recover_username');
     $form->addHidden('token');
     $form->addPassword('recover_password', 'Heslo:')->setRequired('Zvolte si heslo')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaky', 4)->setOption('description', \Nette\Utils\Html::el('td')->setText('Alespoň 4 znaky'));
     $form->addPassword('password_confirm', 'Heslo znovu:')->setRequired('Zadejte prosím heslo ještě jednou pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $form['recover_password']);
     $form->addSubmit('send', 'Změnit');
     $form->onSuccess[] = $this->updateFormSucceded;
     return $form;
 }
Esempio n. 5
0
 /** form for adding new item 
  * 
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentNewItemForm()
 {
     $form = new Form();
     //$userPairs = $this->userRepository->findAll()->fetchPairs('id', 'name');
     if ($this->pageConfig) {
         /** for each item from configuration for this page create form item
          * 
          */
         foreach ($this->pageConfig["form"] as $item => $params) {
             $formItem = NULL;
             switch ($params["type"]) {
                 case "calendar":
                     //$formItem = $form->addDate($item, $params['text'], Vodacek\Forms\Controls\DateInput::TYPE_DATE);
                     //$formItem = $form->addText($item, $params['text'], 40, 100);
                     $formItem = $form->addDatePicker($item, $params['text']);
                     //$formItem->addRule(Form::VALID, 'Zadané datum není platné!');
                     /** check for minimal date */
                     $min = new DateTime('-100 years 00:00');
                     $max = new DateTime('+100 years 00:00');
                     if (isset($params["min"])) {
                         switch ($params["min"]) {
                             case 'today':
                                 $min = new DateTime('-0 days 00:00');
                                 break;
                             default:
                                 $min = new DateTime($params["min"] . ' 00:00');
                                 break;
                         }
                     }
                     /** check for maximal date */
                     if (isset($params["max"])) {
                         switch ($params["max"]) {
                             case 'today':
                                 $max = new DateTime('+0 days 00:00');
                                 break;
                             default:
                                 $max = new DateTime($params["max"] . ' 00:00');
                                 break;
                         }
                     }
                     $formItem->setAttribute('min', $min->format('Y-m-d'))->setAttribute('max', $max->format('Y-m-d'));
                     break;
                 case "shortText":
                     $formItem = $form->addText($item, $params['text'], 40, 100);
                     break;
                 case "longText":
                     $formItem = $form->addTextArea($item, $params['text'], 40, 5);
                     break;
                 case "location":
                     $formItem = $form->addTextArea($item, $params['text'], 40, 3);
                     break;
                 case "select":
                     $formItem = $form->addSelect($item, $params['text'])->setItems($params["options"])->setPrompt('Vyberte');
                     /** set default value for select if any */
                     if (isset($params["defaultValue"])) {
                         $formItem->setDefaultValue($params["defaultValue"]);
                     }
                     break;
             }
             /** if it is mandatory set rule */
             if (isset($params["mandatory"]) && $params["mandatory"]) {
                 $formItem->addRule(Form::FILLED, 'Je nutné vyplnit "' . $params['text'] . '".');
             }
             /** if it has a hint, show it */
             if (isset($params["hint"])) {
                 $formItem->setOption('description', $params["hint"]);
                 if (gettype($params["hint"]) == 'string') {
                     $formItem->setAttribute('title', $params["hint"])->setOption('description', $params["hint"]);
                 }
             }
             /** add placeholder, if any */
             if (isset($params["placeholder"])) {
                 $formItem->setAttribute('placeholder', $params["placeholder"]);
             }
             /** set default value if any */
             if (isset($params["defaultValue"])) {
                 $formItem->setDefaultValue($params["defaultValue"]);
             }
         }
     }
     if (!empty($this->pageConfig['settings']['sendEmail'])) {
         $hintText = 'Tento email nebude zveřejněn; bude vám na něj zaslán odkaz na stránku, na které můžete zde zadané hodnoty zpětně upravit.';
         $session = $this->getSession('agility');
         $defaultVal = '@';
         //$session->email == NULL ? '@' : $session->email;
         $form->addText('email', 'Váš email:', 40, 100)->setDefaultValue($defaultVal)->setType('e-mail')->addRule(Form::FILLED, 'Je nutné zadat email.')->addRule(Form::EMAIL, 'Nezadali jste platnou emailovou adresu.')->setAttribute('title', $hintText)->setOption('description', $hintText);
     }
     $form->addAntispam('kontrolni');
     $form->addSubmit('create', 'Vytvořit');
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'div';
     $renderer->wrappers['pair']['container'] = 'dl';
     $renderer->wrappers['label']['container'] = 'dt';
     $renderer->wrappers['control']['container'] = 'dd';
     $form->getElementPrototype()->class('ajax');
     $form->onSuccess[] = $this->newItemFormSubmitted;
     return $form;
 }