function FileItem::storageSettingsForm

Same name and namespace in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm()
  2. 8.9.x core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm()
  3. 11.x core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::storageSettingsForm()

Overrides EntityReferenceItem::storageSettingsForm

1 method overrides FileItem::storageSettingsForm()
ImageItem::storageSettingsForm in core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
Returns a form for the storage-level settings.

File

core/modules/file/src/Plugin/Field/FieldType/FileItem.php, line 142

Class

FileItem
Plugin implementation of the 'file' field type.

Namespace

Drupal\file\Plugin\Field\FieldType

Code

public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
  $element = [];
  $element['#attached']['library'][] = 'file/drupal.file';
  $element['display_field'] = [
    '#type' => 'checkbox',
    '#title' => $this->t('Enable <em>Display</em> field'),
    '#default_value' => $this->getSetting('display_field'),
    '#description' => $this->t('The display option allows users to choose if a file should be shown when viewing the content.'),
  ];
  $element['display_default'] = [
    '#type' => 'checkbox',
    '#title' => $this->t('Files displayed by default'),
    '#default_value' => $this->getSetting('display_default'),
    '#description' => $this->t('This setting only has an effect if the display option is enabled.'),
    '#states' => [
      'visible' => [
        ':input[name="field_storage[subform][settings][display_field]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $scheme_options = \Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE);
  $element['uri_scheme'] = [
    '#type' => 'radios',
    '#title' => $this->t('Upload destination'),
    '#options' => $scheme_options,
    '#default_value' => $this->getSetting('uri_scheme'),
    '#description' => $this->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.'),
    '#disabled' => $has_data,
  ];
  return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.