You are here

function filefield_sources_form in FileField Sources 7

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

Configuration form for editing FileField Sources settings for a widget.

1 call to filefield_sources_form()
filefield_sources_form_field_ui_field_edit_form_alter in ./filefield_sources.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function filefield_sources_form($instance, &$form_state) {
  $settings = $instance['widget']['settings']['filefield_sources'];

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

  // Make sure all includes are loaded for multistep forms.
  $sources_info = filefield_sources_info(FALSE);
  foreach ($sources_info as $source_name => $source) {
    if (isset($source['file'])) {
      _filefield_sources_form_include($source['module'], $source['file'], $form_state);
    }
  }
  $params = array(
    'form',
    $instance,
  );
  $form['filefield_sources'] = array_merge($form['filefield_sources'], filefield_sources_invoke_all('settings', $params));
  return $form;
}