/** * @param \App\Model\Entities\Article|NULL $article Clanek k editaci * @return Form */ public function create($article = NULL, $tags = []) { $form = $this->baseFormFactory->create(); $form->addText('title', 'system.postName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addText('description', 'system.postDescription')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addCheckbox('published', 'system.isPublished'); //chybi publish_date - datum zverejneni $today = new DateTime(); $form->addText('publishDate', 'system.published')->setType('datetime-local')->setDefaultValue($today->format('d. m. Y, H:i')); //->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok'); $form->addMultiSelect('tags', new Phrase('system.tag', 2))->setItems($tags); $form->addUpload('image', 'system.postImage')->addCondition(Form::FILLED)->addRule(Form::IMAGE, $form->getTranslator()->translate('system.formImage', ['item' => '%label'])); $form->addText('imageSource', 'system.postImageSource'); $form->addTextArea('content', 'system.postContent')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']))->setAttribute('rows', 10); $form->addSubmit('send', 'system.save'); //id, vychozi hodnoty pri editaci $form->addHidden('id'); if ($article !== NULL) { $defaults = $this->getDefaults($article); $form->setDefaults($defaults); } $form->onValidate[] = [$this, 'validateForm']; $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
/** * @param User Uzivatel k editaci * @return Form */ public function create($user = NULL) { $form = $this->baseFormFactory->create(); /* UZIVATELSKA CAST */ $userF = $form->addContainer('user'); $userF->addText('login', 'system.credentialsName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $userF->addPassword('password', 'system.credentialsPassword'); $userF->addPassword('password2', 'system.credentialsPassword')->addConditionOn($form['user']['password'], Form::FILLED)->setRequired(new Phrase('system.requiredItem', ['label' => '%label']))->addRule(Form::EQUAL, new Phrase('system.equalItem', ['label' => '%label']), $form['user']['password']); $userF->addSelect('role', 'system.userRole')->setItems(User::getRoleList()); /* OSOBNI CAST */ $personF = $form->addContainer('person'); $personF->addText('name', 'system.userName')->setRequired(new Phrase('system.requiredItem', ['label' => '%label'])); $personF->addText('surname', 'system.userSurname'); $personF->addUpload('avatar', 'system.userAvatar')->addCondition(Form::FILLED)->addRule(Form::IMAGE, $form->getTranslator()->translate('system.formImage', ['item' => '%label'])); /* OBECNA CAST */ $form->addSubmit('send', 'system.save'); //id, vychozi hodnoty pri editaci $form->addHidden('id'); if ($user !== NULL) { $defaults = $this->getDefaults($user); $form->setDefaults($defaults); } $form->onValidate[] = [$this, 'validateForm']; $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
/** * @param array $types * @param \App\Model\Entities\Vote $vote * @return Form */ public function create($types, $vote = NULL) { $form = $this->baseFormFactory->create(); $form->addText('question', 'system.voteQuestion')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addSelect('type', 'system.voteType')->setItems($types)->setPrompt('Zvolte typ dotazu')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addText('expiration', 'system.voteExpiration')->setType('datetime-local')->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok, hodina:minuta'); $options = $form->addDynamic('options', function (Container $option) { $option->addText('option', 'system.voteOption'); $option->addSubmit('remove', 'system.delete')->addRemoveOnClick(); }, 1); $options->addSubmit('add', 'system.new')->setValidationScope(FALSE)->addCreateOnClick(); $form->addSubmit('send', 'system.save'); $form->addHidden('id'); if ($vote) { $defaults = $this->getDefaults($vote); $form->setDefaults($defaults); $options->setValues($defaults['options']); } else { $today = new DateTime(); $today->modify('+6 month'); $default = ['expiration' => $today->format(self::$dateMask)]; $form->setDefaults($default); } $form->onValidate[] = [$this, 'validateForm']; $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
/** * @return Form */ public function create($mode) { $form = $this->baseFormFactory->create(); $items = $this->getListItem(); $form->addSelect('item', 'items', $items); $form->addHidden('mode', $mode); $form->addSubmit('send', 'system.save'); $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
/** * @return Form */ public function create() { $form = $this->baseFormFactory->create(); $form->addText('username', 'system.credentialsName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']))->setAttribute('autofocus', 'autofocus'); $form->addPassword('password', 'system.credentialsPassword')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addCheckbox('remember', 'system.keepCredentials'); $form->addSubmit('send', 'system.signIn'); $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }
/** * @param \App\Model\Entities\Tag|NULL $tag Tag (nalepka, stitek) k editaci * @return Form */ public function create($tag = NULL) { $form = $this->baseFormFactory->create(); $form->addText('title', 'system.title')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label'])); $form->addSubmit('send', 'system.save'); //id, vychozi hodnoty pri editaci $form->addHidden('id'); if ($tag !== NULL) { $defaults = $this->getDefaults($tag); $form->setDefaults($defaults); } $form->onSuccess[] = [$this, 'formSucceeded']; return $form; }