コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $settings = $this->getSettings();
     $element['file_directory'] = array('#type' => 'textfield', '#title' => t('File directory'), '#default_value' => $settings['file_directory'], '#description' => t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'), '#element_validate' => array(array(get_class($this), 'validateDirectory')), '#weight' => 3);
     // Make the extension list a little more human-friendly by comma-separation.
     $extensions = str_replace(' ', ', ', $settings['file_extensions']);
     $element['file_extensions'] = array('#type' => 'textfield', '#title' => t('Allowed file extensions'), '#default_value' => $extensions, '#description' => t('Separate extensions with a space or comma and do not include the leading dot.'), '#element_validate' => array(array(get_class($this), 'validateExtensions')), '#weight' => 1, '#maxlength' => 256, '#required' => TRUE);
     $element['max_filesize'] = array('#type' => 'textfield', '#title' => t('Maximum upload size'), '#default_value' => $settings['max_filesize'], '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))), '#size' => 10, '#element_validate' => array(array(get_class($this), 'validateMaxFilesize')), '#weight' => 5);
     $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
     $element['uri_scheme'] = array('#type' => 'radios', '#title' => t('Upload destination'), '#options' => $scheme_options, '#default_value' => $this->getSetting('uri_scheme'), '#description' => t('Select where the final files should be stored. Private file storage has significantly more overhead than public files, but allows restricted access to files within this field.'), '#weight' => 6);
     return $element;
 }
コード例 #2
0
ファイル: ImageWidget.php プロジェクト: anatalsceo/en-classe
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['preview_image_style'] = array('#title' => t('Preview image style'), '#type' => 'select', '#options' => image_style_options(FALSE), '#empty_option' => '<' . t('no preview') . '>', '#default_value' => $this->getSetting('preview_image_style'), '#description' => t('The preview image will be shown while editing the content.'), '#weight' => 15);
     return $element;
 }