You are here

function entityreference_dragdrop_field_widget_settings_form in Entity Reference Drag & Drop 7

Implements hook_field_widget_settings_form().

File

./entityreference_dragdrop.module, line 130
Provides a Drag & Drop widget for entity-reference fields.

Code

function entityreference_dragdrop_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  $info = entity_get_info($field['settings']['target_type']);
  $options = array(
    'title' => t('Title'),
    'default' => t('Default'),
  );
  foreach ($info['view modes'] as $view_mode_id => $view_mode) {
    if ($view_mode['custom settings']) {
      $options += array(
        $view_mode_id => t($view_mode['label']),
      );
    }
  }
  $form = array();
  if ($widget['type'] == 'entityreference_dragdrop') {
    $form['view_mode'] = array(
      '#type' => 'select',
      '#title' => t('View mode'),
      '#default_value' => $settings['view_mode'],
      '#options' => $options,
      '#description' => t('Select one of available target entity view mode.'),
    );
    $form['available_entities_label'] = array(
      '#type' => 'textfield',
      '#title' => t('Available entities label'),
      '#default_value' => $settings['available_entities_label'],
      '#description' => t('Type a label that will be displayed above block with available entities.'),
    );
    $form['selected_entities_label'] = array(
      '#type' => 'textfield',
      '#title' => t('Selected entities label'),
      '#default_value' => $settings['selected_entities_label'],
      '#description' => t('Type a label that will be displayed above block with selected entities.'),
    );
    $form['display_filter'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display item filter'),
      '#default_value' => $settings['display_filter'],
    );
  }
  return $form;
}