Пример #1
0
 public function createComponentLoginForm()
 {
     $form = new \Nette\Application\UI\Form($this, 'loginForm');
     $form->addText('username', 'Jméno')->setRequired('Vložte Vaše uživatelské jméno.');
     $form->addPassword('password', 'Heslo')->setRequired('Zadejte prosím vaše heslo.');
     $form->addSubmit('send', 'Přihlásit');
     $form->setAction('#booking');
     return $form;
 }
Пример #2
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setAction('/');
     $form->addHidden('do', 'search-form-submit');
     $form->addText('query');
     $form->addSubmit('search');
     $form->onSuccess[] = $this->onSuccess;
     return $form;
 }
Пример #3
0
 public function createComponentSendMailForm()
 {
     $this->redrawControl('tellafriend');
     $form = new Nette\Application\UI\Form();
     $form->setAction('?');
     $form->addText('mailto', 'Mail to')->setAttribute('placeholder', 'od koho (e-mail)')->setRequired('Zadejte prosím platný e-mail')->setType('email')->addRule($form::EMAIL, 'Zadejte prosím platný e-mail');
     $form->addText('mailfrom', 'Mail from')->setAttribute('placeholder', 'komu (e-mail)')->setRequired('Zadejte prosím platný e-mail')->setType('email')->addRule($form::EMAIL, 'Zadejte prosím platný e-mail');
     $form->addSubmit('send', 'odeslat e-mail');
     $form->onSuccess[] = $this->sendEmail;
     return $form;
 }
 protected function createComponentDatasourceColumnRenameDialog()
 {
     $presenter = $this;
     $form = new Form();
     $form->setAction($this->link('getDatasourceColumnRenameDialog!'));
     $form->translator = $this->translator;
     $form->addHidden('datasource');
     $form->addHidden('column');
     $nameInput = $form->addText('name', 'Data field name:')->setAttribute('class', 'normalWidth');
     $nameInput->addRule(Form::MAX_LENGTH, 'Max length of the data field name is %s characters!', 15)->addRule(Form::MIN_LENGTH, 'You have to input data field name!', 1)->addRule(Form::PATTERN, 'Data field name can contain only letters, numbers and underscore and start with a letter!', '[a-zA-Z_][a-zA-Z0-9_]+')->addRule(function (TextInput $control) use($presenter) {
         //kontrola, jestli existuje data field se stejným jménem
         /** @var HiddenField $datasourceInput */
         $datasourceInput = $control->form->getComponent('datasource');
         $datasource = $presenter->datasourcesFacade->findDatasource($datasourceInput->value);
         $datasourceColumns = $datasource->datasourceColumns;
         foreach ($datasourceColumns as $datasourceColumn) {
             if ($datasourceColumn->name == $control->value) {
                 /** @var HiddenField $columnInput */
                 $columnInput = $control->form->getComponent('column');
                 if ($columnInput->value == $datasourceColumn->datasourceColumnId) {
                     return true;
                 } else {
                     return false;
                 }
             }
         }
         return true;
     }, 'Data field with this name already exists!');
     $form->onError[] = function () use($presenter) {
         //při chybě opět zobrazíme přejmenovávací formulář
         $presenter->template->showDatasourceColumnRenameDialog = true;
         if ($presenter->isAjax()) {
             $presenter->redrawControl('datasourceColumnRenameDialog');
         }
     };
     $form->addSubmit('rename', 'Rename data field')->onClick[] = function (SubmitButton $button) use($presenter) {
         //přejmenování data fieldu
         $formValues = $button->form->values;
         $presenter->datasourcesFacade->renameDatasourceColumn($formValues['datasource'], $formValues['column'], $formValues['name']);
         $presenter->redirect('this');
     };
     $stornoButton = $form->addSubmit('storno', 'Storno');
     $stornoButton->validationScope = array();
     $stornoButton->onClick[] = function () use($presenter) {
         if ($presenter->isAjax()) {
             $presenter->redrawControl('datasourceColumnRenameDialog');
         } else {
             $presenter->redirect('this');
         }
     };
     return $form;
 }
 /**
  * Upraví formulář pro potřeby RequestButtonu.
  * 	Přidá do action backlink, aby formulář i po odeslání věděl kam se má vrátit.
  * 	Když je vráceno na určitý stav formuláře, nastaví mu data.
  * MUSÍ SE VOLAT PO přidání všech FormControlů do Formu a po připojení na Presenter.
  * MÍSTO VOLÁNÍ TÉTO FUNCKE SE MÚŽE POUŽÍT JAKO FORM RequestButtonReceiver
  *
  * @param AppForm
  * @see RequestButtonReceiver
  *
  */
 public static function prepareForm(AppForm $form)
 {
     if (!$form instanceof RequestButtonReceiver) {
         if ($form->getPresenter(false)) {
             $form->setAction(RequestButtonHelper::prepareAction($form, $form->getAction()));
             $form->setValues(RequestButtonHelper::prepareHttpData($form, $form->getHttpData()));
             foreach ($form->getComponents(TRUE, 'RequestButton') as $rb) {
                 $rb->formIsPrepared = true;
             }
         } else {
             throw new InvalidStateException("Form is not attached to Presenter.");
         }
     }
 }