Beispiel #1
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;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }