/** * Registration form * @return Nette\Application\UI\Form */ protected function createComponentRegisterForm() { $form = new Form(); $form->addText('mail', 'Mail:')->setRequired('Zadejte svůj mail')->addRule(Form::EMAIL, 'Nesprávný formát mailu')->setType('email'); $form->addPassword('password', 'Nové heslo:')->setType('password')->setRequired('Zadejte své nové heslo')->addRule(Form::PATTERN, 'Heslo musí obsahovat číslici', '.*[0-9].*')->addRule(Form::PATTERN, 'Heslo musí obsahovat písmeno', '.*[a-z].*')->addRule(Form::MIN_LENGTH, 'Heslo musí být dlouhé min 6 znaků', 6); $form->addPassword('passwordVerify', 'Heslo pro kontrolu:')->setRequired('Zadejte prosím heslo ještě jednou pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $form['password']); $form->addText('nickName', 'Jméno:')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Jméno musí mít alespoň %d znaky', 3); $captcha = $this->captchaManager->generateCaptcha(); $form->addText('captcha', $captcha['question'])->setOption('description', $captcha['hint'])->setRequired('Musíte vyplnit správně kontrolní otázku')->setAttribute(''); $form->addSubmit('submit', 'Registrovat'); $form->onSuccess[] = [$this, 'registerFormSucceeded']; return $form; }
protected function createComponentAddComment() { $form = new Form(); $form->getElementPrototype()->class('ajax'); if (!$this->user->isLoggedIn()) { $form->addText('unregname', 'Vaše jméno')->setRequired('Zadejte jméno'); $captcha = $this->captchaManager->generateCaptcha(); $form->addText('captcha', $captcha['question'])->setAttribute('class', 'captchain')->setOption('description', $captcha['hint'])->setRequired('Musíte vyplnit správně kontrolní otázku')->setAttribute(''); } $form->addTextArea('text', 'Text')->setRequired('Zadejte text'); $form->addSubmit('submit', 'Odeslat'); $form->onSuccess[] = $this->formCommentSucceeded; return $form; }
public function create(ArticleManager $articleManager, CaptchaManager $captchaManager, Presenter $presenter) { $this->articleManager = $articleManager; $this->captchaManager = $captchaManager; $this->presenter = $presenter; $form = new Form(); $form->addText('title', 'Titulek'); $form->addTextArea('aboutUser', 'Něco o vás'); $form->addTextArea('text', 'Váš článek\\připomínka'); if (!$this->presenter->user->isLoggedIn()) { $form->addText('contact', 'Kontakt na vás (jakýkoliv)')->setRequired('Musíte zadat kontakt'); $captcha = $this->captchaManager->generateCaptcha(); $form->addText('captcha', $captcha['question'])->setOption('description', $captcha['hint'])->setRequired('Musíte vyplnit správně kontrolní otázku')->setAttribute(''); } $form->addSubmit('submit', 'Odeslat'); $form->onSuccess[] = [$this, 'newWriterFormSucceeded']; $form->onSuccess[] = function () { $this->presenter->flashMessage('Váš článek byl odeslán redakci'); $this->presenter->redirect('Homepage:'); }; return $form; }