You are here

function _suggestion_admin_submit_autocomplete in Autocomplete Search Suggestions 7

Build an autocomplete form ID to field name hash.

Parameters

array $state: A Drupal form state array.

1 call to _suggestion_admin_submit_autocomplete()
suggestion_admin_settings_form_submit in ./suggestion.admin.inc
Custom submit function for the suggestion setting form.

File

./suggestion.admin.inc, line 503
Administration form for suggestion module.

Code

function _suggestion_admin_submit_autocomplete(array &$state) {
  $hash = array();
  if ($state['values']['suggestion_entry_style'] == 'simple') {
    $hash[trim($state['values']['suggestion_form_id'])] = trim($state['values']['suggestion_field_name']);
  }
  else {
    foreach (preg_split('/\\s*[\\n\\r]+\\s*/s', trim($state['values']['suggestion_autocomplete'])) as $line) {
      if (preg_match('/^\\W*([a-z_0-9]+)\\W+([a-z_0-9]+)\\W*$/', $line, $m)) {
        $hash[$m[1]] = $m[2];
      }
    }
    ksort($hash);
  }
  variable_set('suggestion_autocomplete', $hash);
  unset($state['input']['suggestion_autocomplete']);
  unset($state['values']['suggestion_autocomplete']);
}