コード例 #1
0
 /**
  * Init directory settings
  */
 protected function initDirectorySettings()
 {
     // add descriptions params
     $this->formElements['name']['description'] = 'New directory description';
     $this->formElements['name']['description_params'] = [$this->maxFileNameLength];
     // add extra validators for the file
     $this->formElements['name']['validators'] = [['name' => 'regex', 'options' => ['pattern' => '/^[' . FileManagerBaseModel::getDirectoryNamePattern() . ']+$/', 'message' => 'You can use only latin, numeric and underscore symbols']], ['name' => 'callback', 'options' => ['callback' => [$this, 'validatePossibilityMovingDirectory'], 'message' => 'You can not move a directory to itself or its subdirectories']], ['name' => 'callback', 'options' => ['callback' => [$this, 'validateExistingDirectory'], 'message' => 'Directory already exist']]];
     $this->formElements['name']['max_length'] = (int) $this->maxFileNameLength;
 }
コード例 #2
0
 /**
  * Get form instance
  *
  * @return \Application\Form\ApplicationCustomFormBuilder
  */
 public function getForm()
 {
     // get form builder
     if (!$this->form) {
         // add extra filters
         $this->formElements['name']['filters'] = [['name' => 'stringtolower']];
         // add descriptions params
         $this->formElements['name']['description_params'] = [SettingService::getSetting('file_manager_file_name_length')];
         // add extra validators
         $this->formElements['name']['validators'] = [['name' => 'regex', 'options' => ['pattern' => '/^[' . FileManagerBaseModel::getDirectoryNamePattern() . ']+$/', 'message' => 'You can use only latin, numeric and underscore symbols']], ['name' => 'callback', 'options' => ['callback' => [$this, 'validateExistingDirectory'], 'message' => 'Directory already exist']]];
         // add a directory name length limit
         $this->formElements['name']['max_length'] = (int) SettingService::getSetting('file_manager_file_name_length');
         $this->form = new ApplicationCustomFormBuilder($this->formName, $this->formElements, $this->translator, $this->ignoredElements, $this->notValidatedElements, $this->method);
     }
     return $this->form;
 }