示例#1
0
 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
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;
 }
示例#3
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;
 }
示例#4
0
 /**
  * @return Form
  */
 public function create()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->setRenderer(new \Nextras\Forms\Rendering\Bs3FormRenderer());
     return $form;
 }
 /**
  * @return Form
  */
 public function create()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->setRenderer(new BaseFormRenderer());
     return $form;
 }
示例#6
0
 public function create()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $this->activateBootstrapRenderer($form);
     return $form;
 }
示例#7
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * @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
0
 /**
  * @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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 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;
 }
示例#16
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('page.comments.form.inputs'));
     $form->addText('author', 'author.label', null, Comment::LENGTH_AUTHOR)->setRequired('author.messages.required');
     $form->addTextArea('text', 'text.label', null, 6)->setMaxLength(Comment::LENGTH_TEXT)->setRequired('text.messages.required')->setHtmlId('comment-textarea');
     $form->addSubmit('send', 'submit.caption');
     $form->onSuccess[] = [$this, 'processForm'];
     return $form;
 }
示例#17
0
 /**
  * @Actions login
  */
 protected function createComponentLoginForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.login.form'));
     $form->addText('email', 'email.label')->setAttribute('placeholder', 'email.placeholder')->setAttribute('title', $this->translator->translate('users.login.form.email.title'))->setRequired('email.messages.required')->addRule(Form::EMAIL, 'email.messages.wrongFormat');
     $form->addPassword('password', 'password.label')->setAttribute('placeholder', 'password.placeholder')->setAttribute('title', $this->translator->translate('users.login.form.password.title'))->setRequired('password.messages.required');
     $form->addSubmit('login', 'login.caption');
     $form->onSuccess[] = [$this, 'processLogin'];
     return $form;
 }
示例#18
0
 /**
  * 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;
 }
示例#19
0
 protected function createComponentPaypalPayForm()
 {
     $form = new Form();
     if ($this->translator) {
         $form->setTranslator($this->translator);
     }
     $form->addImage('paypalPay', $this->payImage, 'Pay with PayPal');
     $form->onSuccess[] = callback($this, 'processPayment');
     return $form;
 }
示例#20
0
 protected function createComponentFilter()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('tags.filter.form'));
     $form->getElementPrototype()->class = 'ajax';
     $form->addText('name', 'name.label')->setDefaultValue($this->name);
     $form->addSubmit('filter', 'filter.label')->onClick[] = [$this, 'filterTags'];
     $form->addSubmit('reset', 'reset.label')->onClick[] = [$this, 'filterReset'];
     return $form;
 }
 /**
  * Vytvori prihlasovaci formular
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->addText('username')->setAttribute('placeholder', 'Login')->setRequired('Prosím zadejte vaše přihlašovací jméno');
     $form->addSubmit('submit', 'Odeslat');
     $form->onSuccess[] = function (Form $form) {
         $this->formSucceeded($form);
     };
     return $form;
 }
示例#22
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('images.filterForm'));
     $form->addText('name', 'name.label', 30);
     $form->addSelect('extension', $this->translator->translate('images.filterForm.extension.label'), ['png' => 'PNG', 'jpg' => 'JPG'])->setPrompt($this->translator->translate('images.filterForm.extension.prompt'))->setTranslator(null);
     $form->addText('maxWidth', 'maxWidth.label')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'maxWidth.messages.integerType')->addRule(Form::MIN, 'maxWidth.messages.minValue', 1);
     $form->addText('maxHeight', 'maxHeight.label')->addCondition(Form::FILLED)->addRule(Form::INTEGER, 'maxHeight.messages.integerType')->addRule(Form::MIN, 'maxHeight.messages.integerType', 1);
     $form->addSubmit('filter', 'filter.caption')->onClick[] = [$this, 'processFilter'];
     $form->addSubmit('reset', 'reset.caption')->onClick[] = [$this, 'resetFilter'];
     return $form;
 }
示例#23
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('admin.localization'));
     $form->addSelect('locale', null)->setItems($this->locales)->setDefaultValue($this->locale)->setTranslator(null);
     if (isset($this->locale) and array_key_exists($this->locale, $this->locales)) {
         $form['locale']->setValue($this->locale);
     }
     $form->addSubmit('change', 'form.change.caption');
     $form->onSuccess[] = [$this, 'processLocale'];
     return $form;
 }
示例#24
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.roleRemoval.actions'));
     $form->addSubmit('remove', 'remove')->onClick[] = [$this, 'removeRole'];
     if (!$this->authorizator->isAllowed($this->user, 'user_role', 'remove')) {
         $form['remove']->setDisabled();
     }
     $form->addSubmit('cancel', 'cancel')->onClick[] = [$this, 'cancel'];
     $form->addProtection();
     return $form;
 }
示例#25
0
 /**
  * @return Form
  */
 protected function createComponentSearchForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator);
     $form->addProtection();
     $defaultSearchValue = $this->search ? $this->search->getInput() : NULL;
     $form->addText('search')->setRequired()->setValue($defaultSearchValue);
     $form->addSubmit('submit');
     $form->onSuccess[] = function (Form $form) {
         $this->onSavedSearch($form->getValues()->search);
     };
     return $form;
 }
示例#26
0
 protected function createComponentImageUpload()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('images.uploadForm'));
     $form->addUpload('image', new Phrase('image.label', ['size' => $this->imageSize]))->addRule(Form::IMAGE, 'image.messages.imageFile')->addRule(Form::MAX_FILE_SIZE, new Phrase('image.messages.maxFileSize', ['size' => $this->imageSize]), Image::MAX_FILE_SIZE);
     $form->addSubmit('upload', 'upload.caption');
     $form->onSuccess[] = [$this, 'processImageUpload'];
     if (!$this->authorizator->isAllowed($this->user, 'image', 'upload')) {
         $form['upload']->setDisabled();
     }
     $form->addProtection();
     return $form;
 }
示例#27
0
 protected function createComponentRemovalForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('pageRemoval'));
     $form->addText('check', 'check.label')->setRequired('check.messages.required')->addRule(Form::EQUAL, 'check.messages.notEqual', $this->page->getTitle());
     $form->addSubmit('remove', 'remove.caption')->onClick[] = [$this, 'removePage'];
     $form->addSubmit('cancel', 'cancel.caption')->setValidationScope([])->onClick[] = [$this, 'cancelClick'];
     if (!$this->authorizator->isAllowed($this->user, 'page', 'remove')) {
         $form['remove']->setDisabled();
     }
     $form->addProtection();
     return $form;
 }
示例#28
0
 protected function createComponentNewRoleForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.newRole.form'));
     $form->addText('name', 'name.label', null, Role::LENGTH_NAME)->setRequired('name.messages.required');
     $form->addSelect('parent', $this->translator->translate('users.newRole.form.parent.label'))->setTranslator(null)->setPrompt($this->translator->translate('users.newRole.form.parent.prompt'))->setItems($this->prepareRolesForSelect($this->userFacade->findRolesThatAreNotParents()));
     $form->addSubmit('save', 'save.caption');
     if (!$this->authorizator->isAllowed($this->user, 'user_role', 'create')) {
         $form['save']->setDisabled();
     }
     $form->onSuccess[] = [$this, 'processNewRole'];
     return $form;
 }
示例#29
0
 /**
  * @param User|null $user
  * @return Form
  */
 public function create(User $user = null)
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.user.form'));
     $form->addText('username', 'username.label')->setRequired('username.messages.required');
     $form->addText('email', 'email.label')->setRequired('email.messages.required');
     $form->addText('first_name', 'first_name.label');
     $form->addText('last_name', 'last_name.label');
     $form->addSelect('role', $this->translator->translate('users.user.form.role.label'), $this->prepareRolesForSelect())->setTranslator(null);
     $form->addSubmit('save', 'save.caption');
     if ($user !== null) {
         $this->fillForm($form, $user);
     }
     return $form;
 }
示例#30
0
 /**
  * RenameForm component factory
  *
  * @return \Nette\Application\UI\Form
  */
 protected function createComponentRenameForm()
 {
     $form = new Form();
     $form->setTranslator($this->system->translator);
     $form->addText("newFilename", "New name")->setRequired("New name is required.");
     $form->addHidden("originalFilename");
     $form->addSubmit("send", "OK");
     if (isset($this->selectedFiles[0])) {
         $form["newFilename"]->setDefaultValue($this->selectedFiles[0]);
         $form["originalFilename"]->setDefaultValue($this->selectedFiles[0]);
     }
     $form->onSuccess[] = $this->renameFormSuccess;
     $form->onError[] = $this->parent->parent->onFormError;
     return $form;
 }