You are here

function filefield_paths_field_widget_form_alter in File (Field) Paths 8

Implements hook_form_alter().

File

./filefield_paths.module, line 211
Contains core functions for the File (Field) Paths module.

Code

function filefield_paths_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {

  // Force all File (Field) Paths uploads to go to the temporary file system
  // prior to being processed.
  if (isset($element['#type']) && $element['#type'] == 'managed_file') {
    $settings = $context['items']
      ->getFieldDefinition()
      ->getThirdPartySettings('filefield_paths');
    if (isset($settings['enabled']) && $settings['enabled']) {
      $element['#upload_location'] = \Drupal::config('filefield_paths.settings')
        ->get('temp_location');
    }
  }
}