finder_autocomplete_form_finder_admin_element_edit_alter

Versions
6--1
finder_autocomplete_form_finder_admin_element_edit_alter(&$form, $form_state)

Implementation of hook_form_FORM_ID_alter().

See also

hook_form_FORM_ID_alter()

Code

modules/finder_autocomplete/finder_autocomplete.module, line 42

<?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_match_operator();
    foreach ($operators as $k => $v) {
      $v['description'] = str_replace('Results', 'Autocomplete suggestions', $v['description']);
      $v['description'] = str_replace('submitted values', 'typed keywords', $v['description']);
      $operators[$k] = t($v['description']);
    }

    $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, however it is also the slowest.'),
    );

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

  }
}
?>

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

Mollom CAPTCHA (play audio CAPTCHA)
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.