You are here

function filefield_sources_form in FileField Sources 8

Same name and namespace in other branches
  1. 6 filefield_sources.module \filefield_sources_form()
  2. 7 filefield_sources.module \filefield_sources_form()

Configuration form for editing FileField Sources settings for a widget.

1 call to filefield_sources_form()
filefield_sources_field_widget_third_party_settings_form in ./filefield_sources.module
Implements hook_field_widget_third_party_settings_form().

File

./filefield_sources.module, line 121
Extend FileField to allow files from multiple sources.

Code

function filefield_sources_form($plugin, FormStateInterface $form_state) {
  $settings = $plugin
    ->getThirdPartySetting('filefield_sources', 'filefield_sources');

  // Backward compatibility: auto-enable 'upload'.
  $enabled = _filefield_sources_enabled($settings);
  $form['filefield_sources'] = [
    '#type' => 'details',
    '#title' => t('File sources'),
    '#weight' => 20,
  ];
  $sources = filefield_sources_list();
  $form['filefield_sources']['sources'] = [
    '#type' => 'checkboxes',
    '#title' => t('Enabled sources'),
    '#options' => $sources,
    '#default_value' => $enabled,
    '#description' => t('Select the available locations from which this widget may select files.'),
  ];
  $params = [
    $plugin,
  ];
  $form['filefield_sources'] = array_merge($form['filefield_sources'], filefield_sources_invoke_all('settings', $params));
  return $form;
}