function FileItem::validateDirectory
Same name in other branches
- 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateDirectory()
- 10 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::validateDirectory()
- 11.x 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\FieldTypeCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.