Esempio n. 1
0
 /**
  * Get form instance
  *
  * @return \Application\Form\ApplicationCustomFormBuilder
  */
 public function getForm()
 {
     // get form builder
     if (!$this->form) {
         if (!$this->simpleMode) {
             // get list news categories
             $categories = NewsService::getAllNewsCategories();
             $this->formElements['categories']['values'] = $categories;
             if (!$categories) {
                 unset($this->formElements['categories']);
             }
         } else {
             unset($this->formElements['categories']);
             unset($this->formElements['status']);
         }
         $this->form = new ApplicationCustomFormBuilder($this->formName, $this->formElements, $this->translator, $this->ignoredElements, $this->notValidatedElements, $this->method);
     }
     return $this->form;
 }
Esempio n. 2
0
 /**
  * Get form instance
  *
  * @return \Application\Form\ApplicationCustomFormBuilder
  */
 public function getForm()
 {
     // get form builder
     if (!$this->form) {
         // add extra validators
         $this->formElements['slug']['validators'] = [['name' => 'callback', 'options' => ['callback' => [$this, 'validateSlug'], 'message' => 'Display name already used']]];
         // get categories
         $categories = NewsService::getAllNewsCategories();
         $this->formElements['categories']['values'] = $categories;
         if (!$categories) {
             unset($this->formElements['categories']);
         }
         // add preview for the image
         if ($this->newsImage) {
             $this->formElements['image']['extra_options']['preview'] = true;
             $this->formElements['image']['extra_options']['file_url'] = ApplicationService::getResourcesUrl() . NewsAdministrationModel::getThumbnailsDir() . $this->newsImage;
         }
         $this->form = new ApplicationCustomFormBuilder($this->formName, $this->formElements, $this->translator, $this->ignoredElements, $this->notValidatedElements, $this->method);
     }
     return $this->form;
 }