本文整理汇总了PHP中Nette\Application\UI\Form::addPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addPassword方法的具体用法?PHP Form::addPassword怎么用?PHP Form::addPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::addPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentRegistrationForm
/**
* Formulář pro registraci uživatele
* @return Form
*/
public function createComponentRegistrationForm()
{
$form = new Form();
$form->addText('name', 'Jméno a příjmení:')->setRequired('Je nutné zadat jméno.');
$form->addText('email', 'E-mail:')->setRequired('Je nutné zadat e-mail')->addRule(Form::EMAIL, 'Je nutné zadat platnou e-mailovou adresu.')->addRule(function (TextInput $input) {
return !$this->usersModel->findByEmail($input->value);
}, 'Uživatel s daným e-mailem již existuje.');
$password = $form->addPassword('password', 'Heslo:')->setRequired('Je nutné zadat heslo.')->addRule(Form::MIN_LENGTH, 'Heslo musí mít minumálně 4 znaky.', 4);
$form->addPassword('password2', 'Potvrzení hesla:')->addRule(Form::EQUAL, 'Zadaná hesla se neshodují.', $password);
$form->addSubmit('ok', 'registrovat se')->onClick[] = function (SubmitButton $button) {
//funkce pro vytvoření nového uživatelského účtu a automatick přihlášení uživatele
$data = $button->form->getValues(true);
$user = new User();
$user->active = true;
$user->name = $data['name'];
$user->email = $data['email'];
$user->password = User::encodePassword($data['password']);
$user->role = User::DEFAULT_REGISTERED_ROLE;
if ($this->usersModel->save($user)) {
$this->flashMessage('Registrace byla úspěšně dokončena.');
$this->usersModel->sendRegistrationMail($user);
}
$this->user->login($data['email'], $data['password']);
$this->redirect('Homepage:default');
};
return $form;
}
示例2: createComponentSignUpForm
/**
* Register form factory.
* @return UI\Form
*/
protected function createComponentSignUpForm()
{
$form = new UI\Form();
$form->setTranslator($this->translator->domain('ui'));
// 1. Antispam
$form->addText(self::SPAM1)->setAttribute('style', 'display:none')->addRule(UI\Form::BLANK, 'this-field-should-be-blank');
// 2. Antispam
$form->addText(self::SPAM2, self::SPAM2)->setHtmlId('frm-signUpForm-antispam')->setAttribute('data-spam', self::SPAM2)->setRequired(self::SPAM2)->addRule(UI\Form::EQUAL, self::SPAM2, self::SPAM2);
$form->addText('email2', 'your-email')->setType('email')->setAttribute('placeholder', 'e-g-email-example-com')->addRule(UI\Form::EMAIL, 'please-enter-your-a-valid-email-address-check-for-typos')->setRequired('please-enter-your-a-valid-email-address-check-for-typos')->setAttribute('autofocus');
$form->addText('fullname', 'how-do-you-want-to-be-called')->setAttribute('placeholder', 'placeholder-fullname')->setRequired('please-choose-how-do-you-want-to-be-called-on-the-web');
$form->addText('username', 'login-username')->setAttribute('placeholder', 'placeholder-username')->setRequired('please-choose-your-login-username');
$form->addPassword('password', 'login-password')->setAttribute('placeholder', 'placeholder-password')->setRequired('please-choose-your-login-password')->addRule(UI\Form::MIN_LENGTH, 'please-enter-at-least-d-characters-for-your-password', 8);
$form->addPassword('passwordVerify', 'confirm-password')->setAttribute('placeholder', 'placeholder-password')->setRequired('please-confirm-your-login-password')->addRule(UI\Form::EQUAL, 'please-check-your-different-password', $form['password']);
$form->addSubmit('send', 'register');
$form->onSuccess[] = $this->signUpFormSucceeded;
$form->getElementPrototype()->role('form');
foreach ($form->getControls() as $control) {
if ($control instanceof Controls\Button) {
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
$usedPrimary = TRUE;
} elseif ($control instanceof Controls\TextBase || $control instanceof Controls\SelectBox || $control instanceof Controls\MultiSelectBox) {
$control->getControlPrototype()->addClass('form-control');
} elseif ($control instanceof Controls\Checkbox || $control instanceof Controls\CheckboxList || $control instanceof Controls\RadioList) {
$control->getSeparatorPrototype()->setName('div')->addClass($control->getControlPrototype()->type);
}
}
return $form;
}
示例3: create
/**
* @return \Nette\Application\UI\Form
*/
public function create()
{
$form = new Form();
$form->addGroup($this->user ? 'Upravit uživatele' : 'Přidat uživatele');
$form->addText("name", 'Jméno:')->setRequired('Vyplňte jméno');
$form->addText("email", 'Email:')->setRequired('Vyplňte email')->addRule(function ($ctrl) {
if ($this->user and $this->user->email == $ctrl->getValue()) {
return TRUE;
}
return (bool) (!$this->userFacade->findUserByEmail($ctrl->getValue()));
}, 'Email je obsazen, zvolte prosím jiný');
$password = $form->addPassword("password", 'Heslo:');
$password2 = $form->addPassword("password2", 'Heslo znovu:');
if (!$this->user) {
$password->setRequired('Vyplňte heslo');
$password2->addRule(Form::FILLED, 'Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
} else {
$password2->addConditionOn($password, Form::FILLED)->setRequired('Vyplňte heslo znovu pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $password);
}
$form->addSubmit("send", $this->user ? 'Upravit uživatele' : 'Přidat uživatele');
$form->setRenderer(new Bs3FormRenderer());
$form->onSuccess[] = $this->processForm;
if ($this->user) {
$form->setDefaults(["name" => $this->user->name, "email" => $this->user->email]);
}
return $form;
}
示例4: create
public static function create()
{
$form = new Form();
$form->setRenderer(new BootstrapVerticalRenderer());
$form->addPassword("password", "Heslo")->setRequired("Zadejte prosím heslo, pomocí kterého se budete přihlašovat.")->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků', User::MIN_PASSWORD_LENGTH);
$form->addPassword("passwordVerify", "Heslo znovu")->setRequired("Zadejte prosím stejné heslo ještě jednou.")->addRule(Form::EQUAL, "Zadaná hesla se musí shodovat", $form["password"]);
$form->addSubmit("submit", "Vytvořit heslo")->setAttribute("class", "btn btn-primary btn-lg btn-block");
return $form;
}
示例5: createComponentChangePasswordForm
public function createComponentChangePasswordForm($name)
{
$form = new Form($this, $name);
$form->onSuccess[] = callback($this, $name . 'Submitted');
$form->addPassword('current', 'Zadejte prosím své současné heslo')->setRequired('Vyplnťe prosím své stávající heslo');
$form->addPassword('password', 'Zvolte si prosím své nové heslo')->setRequired('Prosím vyplňte své nové heslo')->addRule(Form::MIN_LENGTH, 'Vaše nové heslo musí být dlouhé nejméně %d znaků.', $this->context->config->get('security.password.minLength', 6));
$form->addPassword('passwordCheck', 'Heslo znovu pro kontrolu:')->setRequired('Prosím vyplňte své druhé helso pro kontrolu.')->addRule(Form::EQUAL, 'Vyplněná hesla se neshodují', $form['password']);
$form->addSubmit('s', 'Změnit!');
$form->addProtection();
}
示例6: create
/**
* Creates Account Settings Form.
* @return Form
*/
public function create()
{
$form = new Form();
$form->addPassword('current', 'Current password')->setRequired('%label is required');
$form->addPassword('new', 'New Password')->setRequired('%label is required');
$form->addPassword('confirm', 'Confirm New Password')->setRequired('New password is required')->addRule(Form::EQUAL, 'New passwords must match', $form['new']);
$form->addSubmit('submit', 'Change Password');
$form->onSuccess[] = [$this, 'formSucceeded'];
return $form;
}
示例7: createComponentPasswordForm
/**
* @return Nette\Application\UI\Form
*/
protected function createComponentPasswordForm()
{
$form = new Form();
$form->addPassword('oldPassword', 'Staré heslo:', 30)->addRule(Form::FILLED, 'Je nutné zadat staré heslo.');
$form->addPassword('newPassword', 'Nové heslo:', 30)->addRule(Form::MIN_LENGTH, 'Nové heslo musí mít alespoň %d znaků.', 6);
$form->addPassword('confirmPassword', 'Potvrzení hesla:', 30)->addRule(Form::FILLED, 'Nové heslo je nutné zadat ještě jednou pro potvrzení.')->addRule(Form::EQUAL, 'Zadná hesla se musejí shodovat.', $form['newPassword']);
$form->addSubmit('set', 'Změnit heslo');
$form->onSuccess[] = $this->passwordFormSubmitted;
return $form;
}
示例8: create
/**
* Creates a SignUpForm.
* @return Form
*/
public function create()
{
$form = new Form();
$form->addText('email', 'Email')->setRequired('%label is required')->addRule(Form::EMAIL, 'Invalid email');
$form->addPassword('password', 'Password')->setRequired('%label is required');
$form->addPassword('confirm', 'Confirm Password')->setRequired('%label is required')->addRule(Form::EQUAL, 'Passwords must match', $form['password']);
$form->addSubmit('submit', 'Sign Up');
$form->onSuccess[] = [$this, 'formSucceeded'];
return $form;
}
示例9: createComponentUserForm
/**
* Formulář na přidání/editaci uživatelů s validačními pravidly.
* @return Form
*/
protected function createComponentUserForm()
{
$form = new Nette\Application\UI\Form();
$form->addText('username')->setAttribute('placeholder', 'Username')->setAttribute('class', 'form-control')->setRequired('Please enter an username.')->addRule(Form::MIN_LENGTH, 'Username must be at least %d characters long.', 3);
$form->addPassword('password')->setAttribute('placeholder', 'Password')->setAttribute('class', 'form-control')->setRequired('Please choose a password.')->addRule(Form::MIN_LENGTH, 'Password must be at least %d characters long.', 6);
$form->addPassword('password2')->setAttribute('placeholder', 'Confirm password')->setAttribute('class', 'form-control')->setRequired('Please repeat your password.')->addRule(Form::EQUAL, 'Passwords must match.', $form['password']);
$form->addText('email')->setAttribute('placeholder', 'Email address')->setAttribute('class', 'form-control')->setRequired('Please enter an email.')->addRule(Form::EMAIL, 'Email address must be valid.');
$form->addSubmit('send', 'Add user')->setAttribute('class', 'btn btn-lg btn-primary btn-block')->onClick[] = [$this, 'userFormSucceeded'];
return $form;
}
示例10: editPass
public function editPass($id)
{
$this->user_id = $id;
$form = new Form();
$form->enableLocalized();
$form->addPassword('password')->setRequired('errors.fill_password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'password');
$form->addPassword('password2')->setRequired('errors.password_authentication')->setAttribute('class', 'form-control')->addRule(Form::EQUAL, 'errors.passwords_match', $form['password'])->setAttribute('placeholder', 'password_retry');
$form->addSubmit('submit', 'edit')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
$form->onSuccess[] = $this->success_form_pass;
return $form;
}
示例11: createComponentRegisterForm
/**
* Register form factory.
* @return Nette\Application\UI\Form
*/
protected function createComponentRegisterForm()
{
$form = new Nette\Application\UI\Form();
$form->addText('login', 'Username:')->setRequired('Please choose your username.');
$form->addPassword('password', 'Password:')->setRequired('Please choose your password.');
$form->addPassword('password2', 'Confirm password:')->setRequired('Please repeat your password.');
$form->addText('email', 'Email:')->setRequired('Please enter your email.');
$form->addSubmit('send', 'Register');
$form->onSuccess[] = array($this, 'registerFormSucceeded');
return $form;
}
示例12: createComponentForm
/**
* Vytvori prihlasovaci formular
* @return \Nette\Application\UI\Form
*/
protected function createComponentForm()
{
$form = new Form();
$form->addPassword('password', 'Heslo')->addRule(Form::MIN_LENGTH, 'Zadané heslo je příliš krátké zadejte heslo alespoň o %d znacích.', 8)->addRule(Form::FILLED, 'Zadejte prosím heslo.');
$form->addPassword('passwordVerify', 'Heslo pro kontrolu')->addConditionOn($form['password'], Form::FILLED)->addRule(Form::FILLED, 'Zadejte prosím heslo ještě jednou pro kontrolu.')->addRule(Form::EQUAL, 'Hesla sa neshodují.', $form['password']);
$form->addSubmit('submit', 'Odeslat');
$form->onSuccess[] = function (Form $form) {
$this->formSucceeded($form);
};
return $form;
}
示例13: configure
protected function configure(Form $form)
{
$form->addText('username', 'locale.form.username')->setRequired('locale.form.username_required');
$form->addText('email', 'locale.form.email')->addRule($form::EMAIL, 'locale.form.email_not_in_order')->setRequired('locale.form.email_address');
$form->addText('forename', 'locale.form.forename');
$form->addText('surname', 'locale.form.surname');
$form->addPassword('password', 'locale.form.password');
$form->addPassword('password_confirm', 'locale.form.password_confirm')->setOmitted()->addConditionOn($form['password'], $form::FILLED, 'locale.form.password_confirm_required')->addRule($form::EQUAL, 'locale.form.password_equal', $form['password']);
$form->addSubmit('submit', 'locale.form.save');
$this->tryAutoFill($form, $this->item);
}
示例14: create
public function create()
{
$form = new Form();
$form->setRenderer(new BootstrapVerticalRenderer());
$form->addPassword("actualPassword", "Aktuální heslo")->setRequired("Zadej prosím své aktuální heslo.")->addRule(Form::MIN_LENGTH, "Heslo musí mít alespoň %d znaků", \Model\Entities\User::MIN_PASSWORD_LENGTH);
$form->addPassword("password", "Nové heslo")->setRequired("Zadej prosím heslo, pomocí kterého se budeš přihlašovat.")->addRule(Form::MIN_LENGTH, "Heslo musí mít alespoň %d znaků", \Model\Entities\User::MIN_PASSWORD_LENGTH);
$form->addPassword("passwordVerify", "Nové heslo znovu")->setRequired("Zadej prosím stejné heslo ještě jednou.")->addRule(Form::EQUAL, "Zadaná hesla se musí shodovat", $form["password"]);
$form->addSubmit("submit", "Změnit heslo")->setAttribute("class", "btn btn-default btn-lg btn-block");
$form->onSuccess[] = array($this, "passwordChangeFormSucceeded");
return $form;
}
示例15: createComponentUserForm
protected function createComponentUserForm()
{
$form = new Form();
$form->addText('email', 'E-mail')->addRule(Form::EMAIL)->setRequired();
$form->addSelect('role', 'Role', [User::ROLE_USER => 'User', User::ROLE_KRYO => 'Kryo', User::ROLE_ADMIN => 'Admin'])->setRequired();
$form->addPassword('password', 'Password')->addRule(Form::MIN_LENGTH, 'Password must be at least %d characters long.', 6)->setRequired();
$form->addPassword('password2', 'Password again')->addRule(Form::EQUAL, 'Passwords are not the same.', $form['password'])->setOmitted();
$form->addSubmit('process', 'Create a new user');
$form->onSuccess[] = $this->userFormSucceeded;
return BootstrapForm::makeBootstrap($form);
}