Exemplo n.º 1
0
 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;
 }
 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;
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Exemplo n.º 6
0
 /**
  * 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});
             }
         }
     }
 }
Exemplo n.º 7
0
 /**
  * @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;
 }
Exemplo n.º 8
0
 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);
         }
     }
 }
 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;
 }
Exemplo n.º 10
0
 /** @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;
 }
 /**
  * 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;
 }
Exemplo n.º 12
0
 /**
  * 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:'******'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:'******'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;
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
     return $polozka_class;
 });
 $template->addFilter('nahodne', function ($max) {
     //Generuje nahodne cislo do template v rozsahu od 0 do max
     return (int) rand(0, $max);
 });
 $template->addFilter('uprav_email', function ($email) {
     //Upravi email aby sa nedal pouzit ako nema
     return Strings::replace($email, ['~@~' => '[@]', '~\\.~' => '[dot]']);
 });
 $template->addFilter('textreg', function ($text, $id_registracia, $max_id_reg) {
     for ($i = $max_id_reg; $i >= 0; $i--) {
         $z_zac = "#REG" . $i . "#";
         //Pociatocna znacka
         $z_alt = "#REG-A" . $i . "#";
         //Alternativna znacka
         $z_kon = "#/REG" . $i . "#";
         //Koncova znacka
         if (($p_zac = strpos($text, $z_zac)) !== FALSE && ($p_kon = strpos($text, $z_kon)) !== FALSE && $p_zac < $p_kon) {
             //Ak som našiel začiatok a koniec a sú v správnom poradí
             $text = substr($text, 0, $p_zac) . (($p_alt = strpos($text, $z_alt)) === FALSE ? $i < $id_registracia ? substr($text, $p_zac + strlen($z_zac), $p_kon - $p_zac - strlen($z_zac)) : '' : ($i < $id_registracia ? substr($text, $p_zac + strlen($z_zac), $p_alt - $p_zac - strlen($z_zac)) : substr($text, $p_alt + strlen($z_alt), $p_kon - $p_alt - strlen($z_alt)))) . substr($text, $p_kon + strlen($z_kon));
             //Od koncovej znacky
         }
     }
     return $text;
 });
 $template->addFilter('vytvor_odkaz', function ($row) use($servise) {
Exemplo n.º 15
0
 /**
  * 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();
     }
 }
 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;
 }