You are here

function entityqueue_field_widget_settings_form in Entityqueue 7

Implements hook_field_widget_settings_form().

File

./entityqueue.module, line 890
Allows users to collect entities in arbitrarily ordered lists.

Code

function entityqueue_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'] + field_info_widget_settings($widget['type']);
  $form = array();
  if ($widget['type'] == 'entityqueue_dragtable') {
    $target_type = $field['settings']['target_type'];
    $info = entity_get_info($target_type);
    $target_label = isset($info['plural label']) ? $info['plural label'] : $info['label'];
    $form['match_operator'] = array(
      '#type' => 'select',
      '#title' => t('Autocomplete matching'),
      '#default_value' => $settings['match_operator'],
      '#options' => array(
        'STARTS_WITH' => t('Starts with'),
        'CONTAINS' => t('Contains'),
      ),
      '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of @entities.', array(
        '@entities' => $target_label,
      )),
    );
    $form['size'] = array(
      '#type' => 'textfield',
      '#title' => t('Size of textfield'),
      '#default_value' => $settings['size'],
      '#element_validate' => array(
        '_element_validate_integer_positive',
      ),
      '#required' => TRUE,
    );
    $form['add_position'] = array(
      '#type' => 'radios',
      '#title' => t('Position for new items'),
      '#options' => array(
        'top' => t('Top of the queue'),
        'bottom' => t('Bottom of the queue'),
      ),
      '#default_value' => $settings['add_position'],
      '#description' => t('Changing this setting will move the autocomplete field above or below the draggable table.'),
    );
  }
  return $form;
}