本文整理汇总了PHP中Nette\Application\UI\Form::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::translate方法的具体用法?PHP Form::translate怎么用?PHP Form::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formSucceeded
public function formSucceeded(Form $form, $values)
{
if ($values->remember) {
$this->user->setExpiration('14 days', FALSE);
} else {
$this->user->setExpiration('20 minutes', TRUE);
}
try {
$this->user->login($values->email, $values->password);
} catch (Nette\Security\AuthenticationException $e) {
$form->addError($form->translate('errors.wrong_login'));
}
}
示例2: editInfo
/**
*
* @param integer $id
* @return Form
*/
public function editInfo($id)
{
$this->user_id = $id;
$user = $this->user_manager->getUser($id);
$form = new Form();
$form->enableLocalized();
$form->addText('name')->setValue($user->name)->setRequired('errors.fill_user_name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name');
$form->addText('email')->setValue($user->email)->setRequired('errors.fill_email')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'email')->addRule(Form::EMAIL, 'errors.fill_email_success')->addRule($this->checkEmailUpdate, 'errros.email_used');
$form->addSelect('role', $form->translate('role'), $this->getListRoles())->setAttribute('class', 'form-control')->setValue($user->user_roles_id)->setRequired('errors.field_required')->setTranslator(null);
$form->addUpload('img')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'errors.img');
$form->addSubmit('submit', 'edit')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
$form->onSuccess[] = $this->success_form_info;
return $form;
}
示例3: create
public function create()
{
$form = new Form();
$form->enableLocalized();
$form->addText('username')->setRequired('errors.fill_user_name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'user_name');
$form->addUpload('img')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'img')->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'errors.img');
$form->addText('email')->setRequired('errors.fill_email')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'email')->addRule(Form::EMAIL, 'errors.fill_email_success')->addRule($this->checkEmail, 'errors.email_used');
$form->addSelect('role', $form->translate('role'), $this->getRoleList())->setRequired('errors.role')->setTranslator(null)->setAttribute('class', 'form-control');
$form->addPassword('password')->setRequired('errors.enter_password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'password');
$form->addPassword('password2')->setRequired('errors.enter_password_retry')->setAttribute('class', 'form-control')->addRule(Form::EQUAL, 'errors.password_must_match', $form['password'])->setAttribute('placeholder', 'password_retry');
$form->addSubmit('submit', 'register')->setAttribute('class', 'btn btn-primary btn-purple btn-flat');
$form->onSuccess[] = $this->success_form_add;
return $form;
}