You are here

public static function FileItem::validateDirectory in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateDirectory()

Form API callback

Removes slashes from the beginning and end of the destination value and ensures that the file directory path is not included at the beginning of the value.

This function is assigned as an #element_validate callback in fieldSettingsForm().

File

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

Class

FileItem
Plugin implementation of the 'file' field type.

Namespace

Drupal\file\Plugin\Field\FieldType

Code

public static function validateDirectory($element, FormStateInterface $form_state) {

  // Strip slashes from the beginning and end of $element['file_directory'].
  $value = trim($element['#value'], '\\/');
  $form_state
    ->setValueForElement($element, $value);
}