Ejemplo n.º 1
0
 protected function createComponentCredentialsForm()
 {
     $form = new BaseaccountForm($this, 'credentialsForm');
     $form->addText('username', null, 30, 30)->setAttribute('placeholder', 'Username')->setDefaultValue($this->identity->username)->addRule(Form::MIN_LENGTH, 'Username must contain at least %d characters.', 3)->addRule(Form::MAX_LENGTH, 'Username is too long. Use maximum of %d characters.', 60)->addRule(Form::PATTERN, 'Username can contain only alphabetical characters or underscore.', '\\w{3,60}');
     $form->addText('email', 'Email', 30, 30)->setAttribute('placeholder', 'Email')->setDefaultValue($this->identity->email)->setRequired('Enter an email please.')->addRule(Form::MAX_LENGTH, 'Email is too long. Use maximum of %d characters.', 255)->addRule(Form::EMAIL, 'Invalid email address.');
     $form->addProtection('Time limit has expired. Please send the form again.', 1800);
     $form->onSuccess[] = $this->credentialsFormSubmitted;
     $form->addSubmit('edit', 'Edit')->setAttribute('class', 'button');
     return $form;
 }
Ejemplo n.º 2
0
 protected function createComponentSignupForm()
 {
     $form = new BaseaccountForm($this, 'signupForm');
     // credentials part
     $form->addText('username', null, 30, 30)->setAttribute('placeholder', 'Username')->addRule(Form::MIN_LENGTH, 'Username must contain at least %d characters.', 3)->addRule(Form::MAX_LENGTH, 'Username is too long. Use maximum of %d characters.', 60)->addRule(Form::PATTERN, 'Username can contain only alphabetical characters or underscore.', '\\w{3,60}');
     $form->addText('email', 'Email', 30, 30)->setAttribute('placeholder', 'Email')->setRequired('Enter an email please.')->addRule(Form::MAX_LENGTH, 'Email is too long. Use maximum of %d characters.', 255)->addRule(Form::EMAIL, 'Invalid email address.');
     $form->addPassword('password', null, 30)->setAttribute('placeholder', 'Password')->setRequired('Enter a password please.')->addRule(Form::MIN_LENGTH, 'Password must contain at least %d characters.', 6);
     $form->addPassword('verifyPassword', null, 30)->setAttribute('placeholder', 'Retype password')->setRequired('Reenter a password please.')->addRule(Form::EQUAL, 'Passwords do not match.', $form['password']);
     $form->addCheckbox('remember', 'Remember me');
     // shift pattern part
     $sysPatternSelection = $this->sysPatternFacade->getFormSelection();
     $form->addSelect('sysPatternSelect', 'Select pattern', $sysPatternSelection);
     reset($sysPatternSelection);
     $defaultPattern = $this->buildDefaultInputPattern(\Nette\Utils\Json::decode(key($sysPatternSelection)));
     $form['patternInput'] = $this->patternInputOverviewFactory->create();
     $form['patternInput']->setDefaultValue($defaultPattern);
     $form->addSubmit('createAccount', 'Create account')->setAttribute('class', 'button');
     // common part
     $form->addProtection('Time limit has expired. Please send the form again.', 1800);
     $form->onSuccess[] = $this->signupFormSubmitted;
     return $form;
 }