Beispiel #1
0
 protected function createComponentFormLogin($name)
 {
     $form = new \Tatami\Forms\BaseForm($this, $name);
     $identity = $this->getUser()->identity;
     if ($identity != null) {
         $form->addHidden('email', $identity->email);
     } else {
         $form->addText('email', 'Email:')->setRequired('Please provide your %name');
     }
     $form->addPassword('password', 'Password:'******'Please provide your %name');
     $form->addCheckbox('remember', 'Remember me');
     $form->addSubmit('btnLogin', 'Login');
     $form->onSuccess[] = callback($this, 'formLoginSubmitted');
 }
Beispiel #2
0
 protected function createComponentFormTest($name)
 {
     $form = new \Tatami\Forms\BaseForm($this, $name);
     $form->addUrl('url', 'Url')->changeValidationMessage('test');
     $form->addEmail('email', 'email');
     $form->addNumber('number', 'Number');
     $form->addRange('range', 'range', 0, 100, 1);
     $form->addColor('color', 'color');
     $form->addDateTime('datetime', 'datetime');
     $form->addDateTimeLocal('datetimelocal', 'datetimelocal');
     $form->addTime('time', 'time');
     $form->addMonth('month', 'month');
     $form->addWeek('week', 'week');
     $form->addSubmit('btnSubmit');
     $form->onSuccess[] = function (\Nette\Application\UI\Form $form) {
         var_dump($form->values);
     };
 }
Beispiel #3
0
 protected function createComponentFormMailSetup($name)
 {
     $form = new \Tatami\Forms\BaseForm($this, $name);
     $form->addGroup('Basic settings')->setOption('container', Html::el('div'));
     $defaultFrom = 'tatami@' . $this->context->expand('%domain%');
     $form->addText('from', 'From')->setDefaultValue($defaultFrom)->setRequired('Please fill %name');
     $form->addText('fromName', 'From name')->setDefaultValue('Tatami');
     $mailers = array('mail' => 'mail() function - default', 'smtp' => 'custom smtp server');
     $mailer = $form->addRadioList('mailer', 'Select mailer', $mailers)->setDefaultValue('mail');
     $mailer->addCondition(Form::EQUAL, 'smtp')->toggle('smtp');
     $form->addCheckbox('ignore', 'Skip sending test email');
     $form->addGroup('Smtp settings')->setOption('container', Html::el('div')->id('smtp'));
     $smtp = $form->addContainer('smtp');
     $encryptions = array('none' => 'none', 'ssl' => 'SSL', 'tls' => 'TLS');
     $smtp->addRadioList('secure', 'Select encryption', $encryptions);
     $smtp->addText('host', 'Server');
     $smtp->addText('port', 'Port');
     $smtp->addText('username', 'Username');
     $smtp->addText('password', 'Password');
     $form->addGroup('')->setOption('container', Html::el(''));
     $form->addSubmit('btnPrevious', 'Previous')->setValidationScope(false)->onClick[] = callback($this, 'goToPreviousStep');
     $form->addSubmit('btnNext', 'Next')->onClick[] = callback($this, 'formMailSetupSubmitted');
     if (isset($this->session->mailSettings)) {
         $form->setDefaults($this->session->mailSettings);
     }
 }