function autocomplete_deluxe_after_build in Autocomplete Deluxe 7.2
Same name and namespace in other branches
- 7 autocomplete_deluxe.module \autocomplete_deluxe_after_build()
FAPI after build callback for the duration parameter type form.
Fixes up the form value by applying the multiplier.
1 string reference to 'autocomplete_deluxe_after_build'
- autocomplete_deluxe_element_process in ./
autocomplete_deluxe.module - Generates the basic form elements and javascript settings.
File
- ./
autocomplete_deluxe.module, line 447 - Define enhanced autocomplete wdiget.
Code
function autocomplete_deluxe_after_build($element, &$form_state) {
// By default drupal sets the maxlength to 128 if the property isn't
// specified, but since the limit isn't useful in some cases,
// we unset the property.
unset($element['textfield']['#maxlength']);
// Set the elements value from either the value field or text field input.
$element['#value'] = isset($element['value_field']) ? $element['value_field']['#value'] : $element['textfield']['#value'];
if (isset($element['value_field'])) {
// Remove any empty double double quoted strings that throw
// off downstream str_replace functions, then trim whitespace.
$element['#value'] = str_replace('""""', '', $element['#value']);
$element['#value'] = trim($element['#value']);
// Replace all cases of double double quotes and one or more spaces with a
// comma. This will allow us to keep entries in double quotes.
$element['#value'] = preg_replace('/"" +""/', '", "', $element['#value']);
// Remove the double quotes at the beginning and the end from the first and
// the last term.
$element['#value'] = substr($element['#value'], 1, strlen($element['#value']) - 2);
// One final check to turn all double double quotes into single double
// quotes. Necessary when re-saving existing values.
$element['#value'] = str_replace('""', '"', $element['#value']);
unset($element['value_field']['#maxlength']);
}
elseif ($form_state['process_input']) {
$element['#value'] = '"' . $element['#value'] . '"';
}
form_set_value($element, $element['#value'], $form_state);
return $element;
}