示例#1
0
 public function createComponentRegistrationForm()
 {
     $form = new \soundake\helpers\MyForm();
     $form->renderStyle = \soundake\helpers\MyForm::BOOTSTRAP;
     $form->setTranslator($this->translator);
     $renderer = $form->getRenderer();
     $renderer->wrappers['error']['container'] = 'ul class="alert alert-error"';
     $form->addText('username', 'Username')->setRequired('Username is your account id and you can need it for next login. Please, fill it up.')->setAttribute('class', 'input-block-level');
     $form->addText('email', 'E-mail')->setRequired('We need your e-mail for next comunication. Please, fill it up.')->addRule(\Nette\Forms\Form::EMAIL, 'E-mail is not valid.')->setDefaultValue('@')->setAttribute('class', 'input-block-level');
     $form->addPassword('password', 'Password')->setRequired('Yes, you must have way to log in. And password is part of it. Please, fill it up.')->setAttribute('class', 'input-block-level');
     $form->addText('name', 'Name')->setRequired('Who are you? Please, give us your name.')->setAttribute('class', 'input-block-level');
     $form->addText('telephone', 'Telephone')->setRequired('We need your phone number for posible contact.')->setAttribute('class', 'input-block-level');
     //$form->addText('telephone','Telephone')->addCondition(UI\Form::FILLED)->addRule(UI\Form::PATTERN, 'Telephone number is not valid.', '/^\+[0-9]{3} ?[0-9]{3} ?[0-9]{3} ?[0-9]{3}$/');
     $form->addText('homepage', 'Homepage')->setAttribute('class', 'input-block-level')->addCondition(UI\Form::FILLED)->addRule(UI\Form::URL, 'URL of Homepage is not valid.');
     $form->addRadioList('sex', 'Sex', $this->context->parameters['sex'])->addRule(UI\Form::FILLED, 'Select your sex.')->setDefaultValue('M');
     $form->addText('organization', 'Firm or organization')->setAttribute('class', 'input-block-level');
     $form->addCheckbox('agree', \Nette\Utils\Html::el()->setHtml('Souhlasím s <a href="/files/PD_podminky_pouzivani_2013.pdf" target="_blank">podmínkami používání PeknyDen.cz</a>.'))->setRequired('Pro všechny akce je nutné souhlas s podmínkami.');
     $form->addSubmit('save', 'Register')->getControlPrototype()->class('btn btn-primary btn-block');
     $form->onSuccess[] = array($this, 'register');
     return $form;
 }