function example_autocomplete_config_form_validate in Search API Autocomplete 7
Validation callback for example_autocomplete_config_form().
The configured SearchApiAutocompleteSearch object can be found in $form_state['search'].
Parameters
array $form: The type-specific config form, as returned by the "config form" callback.
array $form_state: The complete form state of the form.
array $values: The portion of $form_state['values'] that corresponds to the type-specific config form.
See also
example_autocomplete_config_form()
example_autocomplete_config_form_submit()
File
- ./
search_api_autocomplete.api.php, line 372 - Hooks provided by the Search API autocomplete module.
Code
function example_autocomplete_config_form_validate(array $form, array &$form_state, array &$values) {
$f = array();
foreach (explode("\n", $values['user_filters']) as $line) {
if (preg_match('/^\\s*([a-z0-9_:]+)\\s*=\\s*(.*\\S)\\s*$/i', $line, $m)) {
$f[] = $m[1] . '=' . $m[2];
}
else {
form_error($form, t('Write one filter on each line, the field and its value separated by an equals sign (=).'));
}
}
$values['user_filters'] = $f;
}