function filefield_sources_field_widget_form_alter in FileField Sources 8
Implements hook_field_widget_form_alter().
Add file field sources widget's settings to element.
File
- ./
filefield_sources.module, line 98 - Extend FileField to allow files from multiple sources.
Code
function filefield_sources_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
$plugin = $context['widget'];
if (in_array($plugin
->getPluginId(), \Drupal::moduleHandler()
->invokeAll('filefield_sources_widgets'))) {
$element['#filefield_sources_settings'] = $plugin
->getThirdPartySetting('filefield_sources', 'filefield_sources');
// Bundle is missing in element.
$items = $context['items'];
$element['#bundle'] = $items
->getEntity()
->bundle();
}
}