function maxlength_process_element in Maxlength 7.3
Process handler for the form elements that can have maxlength attribute.
1 string reference to 'maxlength_process_element'
- maxlength_element_info_alter in ./
maxlength.module - Implements hook_element_info_alter().
File
- ./
maxlength.module, line 213 - Limit the number of characters in textfields and textareas and shows the amount of characters left.
Code
function maxlength_process_element($element, &$form_state) {
if (isset($element['#maxlength_js_enforce']) && $element['#maxlength_js_enforce']) {
$element['#attributes']['class'][] = 'maxlength_js_enforce';
}
// Move the maxlength property in the attributes of the fields to bypass the
// core validation if we have to truncate the html text.
// We will do our own validation in this case.
if (isset($element['#maxlength_js_truncate_html']) && $element['#maxlength_js_truncate_html']) {
$element['#element_validate'][] = 'maxlength_validate_input';
$element['#attributes']['maxlength'] = $element['#maxlength'];
$element['#attributes']['class'][] = 'maxlength_js_truncate_html';
unset($element['#maxlength']);
}
return $element;
}