finder_autocomplete_form_finder_admin_element_edit_alter

  1. finder
    1. 6.x-1.x
    2. 7.x-1.x
Versions
6.x-1.x – 7.x-1.x finder_autocomplete_form_finder_admin_element_edit_alter(&$form, $form_state)

Implements hook_form_FORM_ID_alter().

See also

hook_form_FORM_ID_alter()

Code

modules/finder_autocomplete/finder_autocomplete.module, line 43

<?php
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.'),
    );

  }
}
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.