本文整理汇总了PHP中Nette\Application\UI\Form::setTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setTranslator方法的具体用法?PHP Form::setTranslator怎么用?PHP Form::setTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::setTranslator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentPageForm
protected function createComponentPageForm()
{
$form = new Form();
$form->setTranslator($this->translator->domain('pageEditForm'));
$form->getElementPrototype()->id = 'page-form';
$form->addText('title', 'title.label', null, Page::LENGTH_TITLE)->setMaxLength(Page::LENGTH_TITLE)->setRequired('title.messages.required')->setAttribute('data-text-length', Page::LENGTH_TITLE)->addRule(Form::MAX_LENGTH, new Phrase('title.messages.maxLength', ['numChars' => Page::LENGTH_TITLE]), Page::LENGTH_TITLE);
$form->addText('publishedAt', 'publishedAt.label', null, 16)->setHtmlId('datetimepicker')->setRequired('publishedAt.messages.required')->addCondition(Form::FILLED)->addRule(Form::MAX_LENGTH, new Phrase('publishedAt.messages.maxLength', ['numChars' => 16]), 16);
$form->addTextArea('intro', 'intro.label', null, 7)->setMaxLength(Page::LENGTH_INTRO)->setRequired('intro.messages.required')->setAttribute('data-text-length', Page::LENGTH_INTRO)->addRule(Form::MAX_LENGTH, new Phrase('intro.messages.maxLength', ['numChars' => Page::LENGTH_INTRO]), Page::LENGTH_INTRO);
$form->addTextArea('text', 'text.label', null, 25);
//->setRequired('text.messages.required');
$form->addText('url', 'url.label', null, 255);
$form->addSelect('lang', 'lang.label')->setItems($this->availableLocales)->setDefaultValue($this->defaultLocale);
if (isset($this->page)) {
$form['lang']->setDisabled();
//$form['lang']->setOmitted();
}
$form->addCheckbox('allowedComments', 'allowedComments.label')->setDefaultValue(true);
$form->addText('keywords', 'keywords.label');
$form->addText('description', 'description.label');
$form->addSubmit('saveAndPublish', 'saveAndPublish.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAndPublish.title'))->onClick[] = [$this, 'processPageSavingAndPublishing'];
$form->addSubmit('saveAsDraft', 'saveAsDraft.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAsDraft.title'))->onClick[] = [$this, 'processPageSavingAsDraft'];
if (!$this->authorizator->isAllowed($this->user, 'page', 'create') or !$this->authorizator->isAllowed($this->user, 'page', 'edit')) {
$form['saveAndPublish']->setDisabled();
$form['saveAsDraft']->setDisabled();
}
$form->addProtection();
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: createComponentLogInForm
/**
* LogIn-in form factory.
* @return Nette\Application\UI\Form
*/
protected function createComponentLogInForm()
{
$form = new Nette\Application\UI\Form();
$form->setTranslator($this->translator->domain('ui'));
$form->addText('username', 'login-username')->setRequired('please-enter-your-username')->setAttribute('autofocus');
$form->addPassword('password', 'login-password')->setRequired('');
$form->addCheckbox('remember', 'keep-me-signed-in');
$form->addSubmit('send', 'log-in');
$form->onSuccess[] = $this->logInFormSucceeded;
// setup form rendering for Twitter Bootstrap
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class=form-group';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class=col-sm-3';
$renderer->wrappers['label']['container'] = 'div class="col-sm-3 control-label"';
$renderer->wrappers['control']['description'] = 'span class=help-block';
$renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
// make form and controls compatible with Twitter Bootstrap
$form->getElementPrototype()->class('form-horizontal');
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;
}
示例4: create
/**
* @return Form
*/
public function create()
{
$form = new Form();
$form->setTranslator($this->translator);
$form->setRenderer(new \Nextras\Forms\Rendering\Bs3FormRenderer());
return $form;
}
示例5: create
/**
* @return Form
*/
public function create()
{
$form = new Form();
$form->setTranslator($this->translator);
$form->setRenderer(new BaseFormRenderer());
return $form;
}
示例6: create
public function create()
{
$form = new Form();
$form->setTranslator($this->translator);
$this->activateBootstrapRenderer($form);
return $form;
}
示例7: createComponentFilterForm
/**
* FilterForm component factory
*
* @return \Nette\Application\UI\Form
*/
protected function createComponentFilterForm()
{
$form = new Form();
$form->setTranslator($this->translator);
$form->addText("phrase")->setDefaultValue($this->system->session->mask)->setAttribute("placeholder", $this->translator->translate("Filter"));
$form->onSuccess[] = $this->filterFormSuccess;
return $form;
}
示例8: createComponentLocationForm
/**
* LocationForm component factory
*
* @return \Nette\Application\UI\Form
*/
protected function createComponentLocationForm()
{
$form = new Form();
$form->setTranslator($this->system->translator);
$form->addText("location")->setDefaultValue($this->getActualDir());
$form->onSuccess[] = $this->locationFormSuccess;
return $form;
}
示例9: create
/**
* Create standard Nette form
* @param bool|true $secured Enable Cross-Site Request Forgery Protection
* @return Form|IForm
*/
public function create($secured = true)
{
$form = new Form();
if ($secured) {
$form->addProtection('Vypršel časový limit, odešlete formulář znovu');
}
$form->setTranslator($this->translator);
return $form;
}
示例10: create
/**
* @return Form
*/
public function create()
{
$form = new Form();
$form->setTranslator($this->translator->domain('tags.tagForm'));
$form->addText('name', 'name.label', null, Tag::LENGTH_NAME)->setRequired('name.messages.required');
$form->addText('color', 'color.label', null, 7)->setRequired('color.messages.required')->setDefaultValue('#')->addRule(Form::PATTERN, 'color.messages.wrongPattern', '^#([0-f]{3}|[0-f]{6})$');
$form->addSubmit('save', 'save.caption');
return $form;
}
示例11: createComponentUploadImgForm
/**
* @return Form
*/
public function createComponentUploadImgForm()
{
$form = new Form();
$form->setTranslator($this->translator->domain('ui'));
$form->addUpload('img', 'pictures', true)->addCondition(Form::FILLED)->addRule(Form::IMAGE, 'only-format-jpg-gif-or-png')->addRule(Form::MAX_FILE_SIZE, 'max-file-size', 2 * 1024 * 1024);
$form->addSubmit('send', 'upload');
$form->onSuccess[] = $this->uploadImgFormSucceeded;
return $form;
}
示例12: createComponentButton
/**
* If some submodule wants to create new button,
* it should call this function for its creation.
*
* @return \Nette\Application\UI\Form $button
*/
public function createComponentButton()
{
$form = new Form();
if ($this->translator) {
$form->setTranslator($this->translator);
}
$form->addImage('paypalCheckOutButton', self::PAYPAL_BUTTON_IMAGE, 'Check out with PayPal');
$form->onSuccess[] = array($this, 'initPayment');
return $form;
}
示例13: createComponentNewDirForm
/**
* NewDirForm component factory
*
* @return \Nette\Application\UI\Form
*/
protected function createComponentNewDirForm()
{
$form = new Form();
$form->setTranslator($this->translator);
$form->addText("name", "New directory")->setRequired("Directory name is required.")->getControlPrototype()->setPlaceholder($this->translator->translate("Name"));
$form->addSubmit("send", "Create");
$form->onSuccess[] = $this->newDirFormSuccess;
$form->onError[] = $this->parent->parent->onFormError;
return $form;
}
示例14: createComponentNewDirForm
/**
* NewDirForm component factory
*
* @return \Nette\Application\UI\Form
*/
protected function createComponentNewDirForm()
{
$form = new Form();
$form->setTranslator($this->system->translator);
$form->addText("name", "Name")->setRequired("Directory name is required.");
$form->addSubmit("send", "Create");
$form->onSuccess[] = $this->newDirFormSuccess;
$form->onError[] = $this->parent->parent->onFormError;
return $form;
}
示例15: createComponentThemeForm
protected function createComponentThemeForm()
{
$themePairs = $this->themes->findAll()->fetchPairs('id', 'slug');
$form = new Form();
$form->setTranslator($this->translator);
$form->addRadioList('theme_id', 'Theme', $themePairs)->setDefaultValue($this->settings->active()->themes_id);
$form->addSubmit('activate', 'Activate');
$form->onSuccess[] = array($this, 'registrationFormSucceeded');
return $form;
}