You are here

public static function VideoEmbedWidget::validateDirectory in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/VideoEmbedWidget.php \Drupal\video\Plugin\Field\FieldWidget\VideoEmbedWidget::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 settingsForm().

File

src/Plugin/Field/FieldWidget/VideoEmbedWidget.php, line 93

Class

VideoEmbedWidget
Plugin implementation of the 'video_embed' widget.

Namespace

Drupal\video\Plugin\Field\FieldWidget

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);
}