本文整理汇总了PHP中Nette\Application\UI\Form::getControls方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::getControls方法的具体用法?PHP Form::getControls怎么用?PHP Form::getControls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Form
的用法示例。
在下文中一共展示了Form::getControls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponentTagForm
protected function createComponentTagForm()
{
$form = new Form();
$form->addText('title', 'title:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('slug', 'slug:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('color', 'color:')->setRequired()->getControlPrototype()->addClass('color {minV:0.9} form-control');
$form->addText('bg_color', 'bg_color:')->setRequired()->getControlPrototype()->addClass('color {maxV:0.5} form-control');
$form->addCheckbox('active', 'active:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addSubmit('send', 'Save tag')->getControlPrototype()->setName('button')->addClass('btn btn-success')->setHtml('<span class="glyphicon glyphicon-ok"></span>');
$form->onSuccess[] = array($this, 'tagFormSucceeded');
// 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-10';
$renderer->wrappers['label']['container'] = 'div class="col-sm-2 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');
// <form 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例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: loadFromEntity
/**
* Fills the form fields with entity data
* @param Nette\Application\UI\Form $form
* @param vBuilder\Orm\Entity $entity
* @param bool true for setDefaults, false for setValues
*/
public static function loadFromEntity(Nette\Application\UI\Form $form, vBuilder\Orm\Entity $entity, $defaults = true)
{
$data = $entity->getData();
$method = $defaults ? 'setDefaultValue' : 'setValue';
foreach ($form->getControls() as $control) {
if (static::isControlSupported($control)) {
$name = $control->getName();
if (isset($entity->{$name})) {
$form[$name]->{$method}($entity->{$name});
}
}
}
}
示例7: makeBootstrap
/**
* @param Form $form
* @return Form
*/
public static function makeBootstrap(Form $form)
{
$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-9';
$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';
$form->getElementPrototype()->class('form-horizontal');
foreach ($form->getControls() as $control) {
if ($control instanceof Button) {
$control->setAttribute('class', empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-default');
$usedPrimary = true;
} elseif ($control instanceof TextBase || $control instanceof SelectBox || $control instanceof MultiSelectBox) {
$control->setAttribute('class', 'form-control');
} elseif ($control instanceof Checkbox || $control instanceof CheckboxList || $control instanceof RadioList) {
$control->getSeparatorPrototype()->setName('div')->class($control->getControlPrototype()->type);
}
}
return $form;
}
示例8: activateBootstrapRenderer
public function activateBootstrapRenderer(Nette\Application\UI\Form $form)
{
$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-9';
$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);
}
}
}
示例9: createComponentPostForm
protected function createComponentPostForm()
{
$form = new Form();
$form->addText('title', 'Titulek:')->setRequired();
$form->addTextArea('content', 'Obsah:', 55, 8)->setRequired()->setAttribute('class', 'mceEditor');
$form->getElementPrototype()->onsubmit('tinyMCE.triggerSave()');
$form->addSubmit('send', 'Vložit článek');
foreach ($form->getComponents(TRUE, 'SubmitButton') as $button) {
if (!$button->getValidationScope()) {
continue;
}
$button->getControlPrototype()->onclick('tinyMCE.triggerSave()');
}
// setup form rendering
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class="form-group text-center"';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class="col-sm-10"';
$renderer->wrappers['label']['container'] = 'div class="control-label text-center col-sm-1"';
$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, 'postFormSucceeded');
return $form;
}
示例10: create
/** @return Form */
public function create()
{
$f = new Form();
$f->addText('name', 'Jméno:');
//->setRequired();
$f->addText('surname', 'Příjmení:');
//->setRequired();
$f->addText('institution', 'Pracoviště:');
$f->addText('project', 'Projekt:');
$f->AddText('www', 'web:');
$f->addText('date', 'Datum setkání:')->setAttribute('placeholder', 'rrrr-mm-dd');
$f->addTextArea('note', 'Poznámka')->setAttribute('rows', '10');
$f->addMultiUpload('img', 'Vizitka');
$f->addUpload('foto', 'Foto:');
$f->addSubmit('submit', 'Uložit');
// setup form rendering
$renderer = $f->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-8';
$renderer->wrappers['label']['container'] = 'div class="col-sm-2 control-label"';
$renderer->wrappers['control']['description'] = 'span class=help-block';
$renderer->wrappers['control']['errorcontainer'] = 'span class=help-block';
$f->getElementPrototype()->class('form-horizontal');
foreach ($f->getControls() as $control) {
if ($control instanceof Controls\Button) {
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-success' : '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 $f;
}
示例11: createComponentPasswordRecoveryForm
/**
* Register form factory.
* @return UI\Form
*/
protected function createComponentPasswordRecoveryForm()
{
$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->addSubmit('send', 'send');
$form->onSuccess[] = $this->passwordRecoveryFormSucceeded;
$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;
}
示例12: createComponentSetNewPasswordForm
/**
* Register form factory.
* @return UI\Form
*/
protected function createComponentSetNewPasswordForm()
{
$form = new UI\Form();
// 1. Antispam
$form->addText(self::SPAM1)->setAttribute('style', 'display:none')->addRule(UI\Form::BLANK);
// 2. Antispam
$form->addText(self::SPAM2, 'Please type in the word: ' . self::SPAM2)->setHtmlId('frm-signUpForm-antispam')->setAttribute('data-spam', self::SPAM2)->setRequired('Please type in the word: ' . self::SPAM2)->addRule(UI\Form::EQUAL, 'Please type in the word %s', self::SPAM2);
$form->addPassword('password', 'Login password:')->setAttribute('placeholder', 'e.g., ********')->setRequired('Please choose your login password.')->addRule(UI\Form::MIN_LENGTH, 'Please enter at least %d characters for your password.', 4);
$form->addPassword('passwordVerify', 'Confirm password:')->setAttribute('placeholder', 'e.g., ********')->setRequired('Please confirm your login password.')->addRule(UI\Form::EQUAL, 'Please check your different password.', $form['password']);
$form->addSubmit('send', 'Set password');
$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;
}
示例13: createComponentPostForm
protected function createComponentPostForm()
{
$form = new Form();
$form->addText('title_en', 'title_en:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('slug_en', 'slug_en:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('title_cs', 'title_cs:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('slug_cs', 'slug_cs:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addText('label', 'label:')->setRequired()->getControlPrototype()->addClass('form-control');
$form->addTextArea('body_cs', 'body_cs:')->getControlPrototype()->addClass('form-control')->addRows('10');
$form->addTextArea('body_en', 'body_en:')->getControlPrototype()->addClass('form-control')->addRows('10');
$form->addText('date', 'date:')->setType('datetime')->setDefaultValue(new \Nette\Utils\DateTime())->getControlPrototype()->addClass('form-control');
$form->addSubmit('send', 'Save post');
//->getControlPrototype()->setName('button')->addClass('btn btn-success')->setHtml('messages.logInForm.PleaseEnterYourPassword <span class="glyphicon glyphicon-ok"></span>');
// TODO zkusit někdy přidání stylu při definici formuláře setAttribute:
// https://forum.nette.org/cs/24499-jak-nastavit-class-submitu-ve-formulari#p163765
//$form->addSubmit('save', 'Odeslat')->setAttribute('class', 'btn btn-primary');
$form->onSuccess[] = array($this, 'postFormSucceeded');
// 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-10';
$renderer->wrappers['label']['container'] = 'div class="col-sm-2 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');
// <form 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;
}
示例14: validateAjax
/**
* Validuje formular zaslany ajaxem
* @param Form $form
*/
public function validateAjax(Form $form)
{
if ($this->presenter->isAjax()) {
$form->cleanErrors();
foreach ($form->getControls() as $control) {
$control->cleanErrors();
}
$form->onSuccess = [];
$this->redrawControl();
}
}
示例15: createComponentUploadImg
protected function createComponentUploadImg()
{
$form = new Form();
$form->addMultiUpload("imgs", "Obrázek")->addRule(Form::IMAGE, "Lze vložit pouze obrázky");
// ->addRule(Form::MAX_FILE_SIZE, 'Maximální velikost souboru je 5 MB.', '50000');
$form->addHidden('folder', $this->getParameter('galId'));
$form->addSubmit('create', 'Nahrát');
$form->addSubmit('cancel', 'Zrušit')->setValidationScope(FALSE);
// setup form rendering
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = NULL;
$renderer->wrappers['pair']['container'] = 'div class="form-group text-center"';
$renderer->wrappers['pair']['.error'] = 'has-error';
$renderer->wrappers['control']['container'] = 'div class="col-sm-10"';
$renderer->wrappers['label']['container'] = 'div class="control-label text-center col-sm-1"';
$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, 'uploadImgSuccess');
return $form;
}