function suggestion_admin_settings_form_validate in Autocomplete Search Suggestions 7
Custom validation.
1 string reference to 'suggestion_admin_settings_form_validate'
- suggestion_admin_settings_form in ./
suggestion.admin.inc - Menu callback to configure suggestion settings.
File
- ./
suggestion.admin.inc, line 419 - Administration form for suggestion module.
Code
function suggestion_admin_settings_form_validate($form, &$state) {
if ($state['values']['suggestion_atoms_min'] >= $state['values']['suggestion_atoms_max']) {
form_set_error('suggestion_atoms_min', t('The minimum must be less than the maximum.'));
form_set_error('suggestion_atoms_max', t('The maximum must be greater than the minimum.'));
}
if ($state['values']['suggestion_entry_style'] == 'simple') {
if (!preg_match('/^[a-z_0-9]+$/', trim($state['values']['suggestion_field_name']))) {
form_set_error('suggestion_field_name', t('Illegal character(s) in field name.'));
}
if (!preg_match('/^[a-z_0-9]+$/', trim($state['values']['suggestion_form_id']))) {
form_set_error('suggestion_form_id', t('Illegal character(s) in form id.'));
}
}
elseif (!preg_match('/\\W*([a-z_0-9]+)\\W+([a-z_0-9]+)\\W*/s', $state['values']['suggestion_autocomplete'])) {
form_set_error('suggestion_autocomplete', t('Auto-complete must be in the form "form_id:field_name", (one per line).'));
}
}