protected function createComponentOptionsForm() { $form = new Form(); $form->setTranslator($this->translator->domain('options.form')); $form->addText('blog_title', 'blogTitle.label', null, 255)->setRequired('blogTitle.messages.required'); $form->addText('blog_subtitle', 'blogSubtitle.label', null, 255); $form->addText('copyright', 'copyright.label', null, 255)->setRequired('copyright.messages.required'); $form->addText('articles_per_page', 'articlesPerPage.label', null, 2)->setRequired('articlesPerPage.messages.required')->addRule(function ($input) { if (Validators::is($input->value, 'numericint:1..')) { return true; } return false; }, 'articlesPerPage.messages.wrongInput'); $form->addText('google_analytics_measure_code', 'gaMeasureCode.label'); $form->addSubmit('save', 'save.caption'); $form->onSuccess[] = [$this, 'processForm']; $form->addProtection(); if (!$this->authorizator->isAllowed($this->user, 'options', 'edit')) { $form['save']->setDisabled(); } $form->setDefaults($this->optionFacade->loadOptions()); return $form; }
protected function startup() { parent::startup(); $this->userEntity = $this->user->getIdentity(); $this->options = $this->optionFacade->loadOptions(); }