本文整理汇总了PHP中Nette\Application\UI\Form::getElementPrototype方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getElementPrototype方法的具体用法?PHP Form::getElementPrototype怎么用?PHP Form::getElementPrototype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::getElementPrototype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @return Form
*/
public function create($kat = null, $page = null, $id_user = null)
{
// nastaveni paginatoru
$paginator = new Nette\Utils\Paginator();
$paginator->setItemsPerPage(6);
// def počtu položek na stránce
$paginator->setPage($page);
// def stranky
// selekce upozorneni
$alerts = $this->database->findAll('alert')->where('id_user', $id_user);
if ($kat == 'read') {
// prectene
$alerts = $alerts->where('visited', 1);
} else {
// neprectene
$alerts = $alerts->where('visited', 0);
}
$alerts = $alerts->order('added DESC')->order('id DESC');
// prideleni produktu na stranku
$paginator->setItemCount($alerts->count('*'));
$this->alerts = $alerts->limit($paginator->getLength(), $paginator->getOffset());
$this->kat = $kat;
// form
$form = new Form();
$form->getElementPrototype()->class('ajax form');
foreach ($this->alerts as $alert) {
$form->addCheckbox($alert->id);
}
$form->addSubmit('btndel', 'Smazat upozornění')->setAttribute('class', 'btn btn-primary');
$form->addSubmit('btnvis', 'Označit jako přečtené')->setAttribute('class', 'btn btn-default');
$form->onSuccess[] = array($this, 'formSucceeded');
$form->onError[] = array($this, 'formNotSucceeded');
return $form;
}
示例2: 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;
}
示例3: create
/**
* @return Form
*/
public function create($role)
{
$rights = $this->database->table('rights')->fetchPairs('id', 'name');
$form = new Form();
$form->addHidden('id');
$form->addText('username', 'uživatelské jméno: ')->addRule(Form::FILLED, 'Zadejte prosím jméno.');
$form->addText('email', 'email: ')->addRule(Form::FILLED, 'Zadejte prosím email.')->addRule(Form::EMAIL, 'Email by měl mít platný formát');
if (in_array("admin", $role)) {
// editace prav jen adminem
$form->addSelect('rights_id', 'level práv: ', $rights);
}
$form->addSubmit('submit', 'uložit');
$form->addProtection('Vypršel časový limit, odešlete formulář znovu');
//bootstrap vzhled
$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'] = '';
$renderer->wrappers['label']['container'] = 'div class="control-label col-sm-5"';
$renderer->wrappers['control']['description'] = 'span class=help-block';
$renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
$form->getElementPrototype()->class('form-horizontal col-sm-12');
return $form;
}
示例4: 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;
}
示例5: createComponentContactForm
/**
* Contact form
*/
protected function createComponentContactForm()
{
// vytvoříme element
$products = array('Zakladni' => 'Základní', 'Pokrocile' => 'Pokročilé', 'NaMiru' => 'Na Míru', 'Ostatni' => 'Ostatní');
$form = new Form();
$form->addText('name', 'Jméno ')->addRule(Form::FILLED, 'Zadejte jméno');
$form->addSelect('product', 'Produkt:', $products)->setRequired()->setDefaultValue('Zakladni');
$form->addText('phone', 'Telefon ');
$form->addText('email', 'Email')->addRule(Form::FILLED, 'Zadejte email')->addRule(Form::EMAIL, 'Email nemá správný formát');
$form->addTextarea('message', 'Zpráva', 999, 5)->addRule(Form::FILLED, 'Zadejte zprávu');
$form->addSubmit('send', 'Odeslat');
// setup form rendering
$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-12';
$renderer->wrappers['label']['container'] = 'div class="col-sm-12 text-center"';
$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-green btn-block btn-lg' : '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);
}
}
$form->onSuccess[] = $this->processContactForm;
return $form;
}
示例6: create
public function create()
{
$form = new Form();
$form->addText('workStart', 'Začátek', 3, 5)->setRequired('Vyplňte pole "Začátek prac. doby".')->setDefaultValue($this->defaultItemTime['workStart'])->setHtmlId('workStart')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Začátek prac. doby" lze zadat pouze
čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
$form->addText('workEnd', 'Konec', 3, 5)->setRequired('Vyplňte pole "Konec prac. doby".')->setDefaultValue($this->defaultItemTime['workEnd'])->setHtmlId('workEnd')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Konec prac. doby" lze zadat pouze
čas v 24 hodinovém formátu po půlhodinách.', '([01]?[0-9]|2[0-3]):(0|3)0');
$form->addText('lunch', 'Oběd', 3, 5)->setRequired('Vyplňte pole "Oběd".')->setDefaultValue($this->defaultItemTime['lunch'])->setHtmlId('lunch')->setAttribute('class', 'input-time')->addRule(Form::PATTERN, 'Do pole "Oběd" lze zadat pouze
čas v ve formátu s čárkou. (např. 1 nebo 1,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
$form->addText('otherHours', 'Ostatní hod.')->setDefaultValue($this->defaultItemTime['otherHours'])->setHtmlId('otherHours')->setAttribute('class', 'input-time')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Do pole "Ostaní hodiny" lze zadat pouze
čas ve formátu s čárkou.(např. 6 nebo 6,5)', '^(0|[1-9]|1[0-9]|2[0-3])(,(0|5))?$');
$form->addText('locality', 'Místo pracoviště', 28, 40)->setRequired('Vyplňte pole "Místo pracoviště".')->setHtmlId('locality')->getControlPrototype()->class = 'item-text-input';
$form->addText('description', 'Popis práce', 28, 30)->getControlPrototype()->class = 'item-text-input';
$form->addText('descOtherHours', 'Komentář k ostat. hod. (např. svátek)', 28, 30)->addConditionOn($form['otherHours'], Form::FILLED)->addCondition(Form::FILLED)->addRule(function ($item, $arg) {
return \InvoiceTime::processTime($arg) == '00:00:00' ? false : true;
}, self::OTHER_HOURS_ZERO_TIME_ERROR_MSG, $form['otherHours']);
$form['descOtherHours']->getControlPrototype()->class = 'item-text-input';
// time control buttons
$form->addButton('workStartAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => -30]));
$form->addButton('workStartSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workStart']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 0, 'val' => 30]));
$form->addButton('workEndAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => 30]));
$form->addButton('workEndSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['workEnd']->control->attrs['id'], 'slider' => 'slider_range', 'pos' => 1, 'val' => -30]));
$form->addButton('lunchAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => -30]));
$form->addButton('lunchSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['lunch']->control->attrs['id'], 'slider' => 'slider_lunch', 'val' => 30]));
$form->addButton('otherHoursAdd', '+')->setAttribute('class', self::BTN_TIME_ADD_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
$form->addButton('otherHoursSub', '-')->setAttribute('class', self::BTN_TIME_SUB_CLASS)->setAttribute('data-time', Json::encode(['inputID' => $form['otherHours']->control->attrs['id'], 'slider' => 'slider_time_other', 'val' => 0]));
$form->addSubmit('save', 'Uložit řádek');
$form->getElementPrototype()->id = 'update-form';
return $form;
}
示例7: createComponentSignInForm
protected function createComponentSignInForm()
{
$form = new Form();
$form->addText('username', 'Uživatelské jméno:')->setRequired('Prosím vyplňte své uživatelské jméno.');
$form->addPassword('password', 'Heslo:')->setRequired('Prosím vyplňte své heslo.');
$form->addCheckbox('remember', 'Zůstat přihlášen');
$form->addSubmit('send', 'Přihlásit');
// setup form rendering
$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-6"';
$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);
}
}
$form->onSuccess[] = array($this, 'signInFormSucceeded');
return $form;
}
示例8: create
public function create()
{
$form = new Form();
$form->getElementPrototype()->addClass('form-horizontal');
$form->setRenderer(new Bs3FormRenderer());
return $form;
}
示例9: 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;
}
示例10: createComponentDateForm
/**
* @return \Nette\Forms\Form
*/
public function createComponentDateForm()
{
$form = new Form();
$form->getElementPrototype()->style = 'margin: 0;';
$form->addDatePicker('paginatorDate')->addRule(Form::VALID, 'Entered date is not valid!')->addCondition(Form::FILLED)->addRule(Form::RANGE, 'Entered date is not within allowed range.', array($this->getPaginator()->getOldestDate(), $this->getPaginator()->getNewestDate()));
$form['paginatorDate']->setDefaultValue($this->getPaginator()->getDate());
$form->onSuccess[] = callback($this, 'formSubmitted');
return $form;
}
示例11: createComponentForm
/**
* @return Form
*/
protected function createComponentForm()
{
$form = new Form();
$form->getElementPrototype()->class('navbar-form navbar-right');
$form->addText('text')->setAttribute('placeholder', 'Search project')->getControlPrototype()->class('form-control');
$form->addSubmit('search', 'Search')->getControlPrototype()->class('btn btn-success');
$form->onSuccess[] = $this->formSuccess;
return $form;
}
示例12: createComponentFormPasswordGenerator
protected function createComponentFormPasswordGenerator()
{
$form = new Form();
$form->getElementPrototype()->name('settingsForNewPassword');
$form->addText('password', 'New Password:');
$form->addText('salt', 'Salt:');
$form->addSubmit('generate', 'Generate');
$form->onSuccess[] = [$this, 'passwordGeneratorFormSubmitted'];
return $form;
}
示例13: createComponentForm
/**
* Vytvori prihlasovaci formular
* @return \Nette\Application\UI\Form
*/
protected function createComponentForm()
{
$form = new Form();
$form->setTranslator($this->translator);
$form->getElementPrototype()->id = 'loginform';
$form->addText('login', NULL)->setAttribute('placeholder', 'Login')->setRequired('Zadejte prosím login.');
$form->addPassword('password', NULL)->setAttribute('placeholder', 'Heslo')->setRequired('Zadejte prosím heslo.');
$form->addSubmit('makeLogin', 'Přihlásit');
return $form;
}
示例14: createComponentForm
/**
* @return Form
*/
protected function createComponentForm()
{
$form = new Form();
$form->getElementPrototype()->class = 'sign-form';
$form->addText('username', 'Login')->setRequired();
$form->addPassword('password', 'Password')->setRequired();
$form->addSubmit('submit', 'Sign in');
$form->onSuccess[] = [$this, 'processForm'];
return $form;
}
示例15: createComponentForm
protected function createComponentForm()
{
$form = new Form();
$form->addSelect('year', '', TimeUtils::generateYearsForSelect());
$form->addSelect('month', '', TimeUtils::getMonths())->setPrompt('Celý rok');
$form->addSubmit('filter', 'Zobraz výčetky')->setOmitted();
$form->getElementPrototype()->id = 'form-filter';
$form->onSuccess[] = $this->processFilter;
return $form;
}