You are here

function finder_autocomplete_form_finder_admin_element_edit_alter in Finder 7

Same name and namespace in other branches
  1. 6 modules/finder_autocomplete/finder_autocomplete.module \finder_autocomplete_form_finder_admin_element_edit_alter()

Implements hook_form_FORM_ID_alter().

See also

hook_form_FORM_ID_alter()

File

modules/finder_autocomplete/finder_autocomplete.module, line 42
The finder autocomplete module.

Code

function finder_autocomplete_form_finder_admin_element_edit_alter(&$form, $form_state) {
  $finder =& $form_state['storage']['finder'];
  $finder_element_id =& $form_state['storage']['finder_element_id'];
  $element =& $form_state['storage']['finder_element_defaults'];
  if ($element->element == 'autocomplete') {
    $form['settings']['form']['field_prefix'] = array(
      '#type' => 'textfield',
      '#title' => t('Field prefix'),
      '#default_value' => $element->settings['form']['field_prefix'],
      '#weight' => 150,
      '#description' => t('Displayed directly before the form input field.'),
    );
    $form['settings']['form']['field_suffix'] = array(
      '#type' => 'textfield',
      '#title' => t('Field suffix'),
      '#default_value' => $element->settings['form']['field_suffix'],
      '#weight' => 160,
      '#description' => t('Displayed directly after the form input field.'),
    );
    $form['settings']['form']['maxlength'] = array(
      '#type' => 'textfield',
      '#title' => t('Max length'),
      '#default_value' => $element->settings['form']['maxlength'],
      '#weight' => 170,
      '#description' => t('
        The maximum amount of characters to accept as input.
        <em> Using this may truncate longer field values and fail with exact matching.</em>'),
    );
    $form['settings']['form']['size'] = array(
      '#type' => 'textfield',
      '#title' => t('Size'),
      '#default_value' => $element->settings['form']['size'],
      '#weight' => 180,
      '#description' => t('Width of the textfield (in characters).  Leave blank to default to <em>60</em>'),
    );
    $form['settings']['form']['max_suggestions'] = array(
      '#type' => 'textfield',
      '#title' => t('Max suggestions'),
      '#default_value' => $element->settings['form']['max_suggestions'] ? $element->settings['form']['max_suggestions'] : 10,
      '#weight' => 190,
      '#description' => t('It is a good idea to limit the number of autocomplete suggestions that appear.'),
    );
    $operators = finder_condition_args();
    foreach ($operators as $k => $v) {
      $operators[$k] = finder_condition_args_label($v, t('autocomplete suggestions'), t('typed keywords'));
    }
    $form['settings']['form']['match'] = array(
      '#type' => 'radios',
      '#title' => t('Autocomplete matching'),
      '#default_value' => $element->settings['form']['match'] ? $element->settings['form']['match'] : 'c',
      '#options' => $operators,
      '#weight' => 190,
      '#description' => t('"Contains" is the most common autocomplete match method.  <a href="!url">Configure custom matching</a>.'),
    );
    $form['settings']['form']['autosubmit'] = array(
      '#type' => 'checkbox',
      '#title' => t('Submit upon selection'),
      '#default_value' => $element->settings['form']['autosubmit'] ? $element->settings['form']['autosubmit'] : 0,
      '#weight' => 200,
      '#description' => t('
        Normally selecting a suggested autocomplete value (with mouse click or
        enter button) does not submit the form, even if the entire value was
        typed by the user, this option shortens the workflow for single element
        finders by automatically submitting the form when the selection is
        made.'),
    );
    $form['settings']['form']['delimit_autocomplete'] = array(
      '#type' => 'textfield',
      '#title' => t('Treat delimited values as separate keywords for autocomplete suggestions'),
      '#default_value' => isset($element->settings['form']['delimit_autocomplete']) ? $element->settings['form']['delimit_autocomplete'] : '',
      '#weight' => 210,
      '#description' => t('For example, if you type a space here, the autocompleted value will be expanded into a value for each word.  Leave empty to disable this feature.'),
    );
  }
}