You are here

function _maxlength_add_maxlength_attributes in Maxlength 7.3

Add maxlength attributes.

1 call to _maxlength_add_maxlength_attributes()
_maxlength_children in ./maxlength.module
Recursively add the #maxlength_js and #maxlength properties to the elements of a form.

File

./maxlength.module, line 201
Limit the number of characters in textfields and textareas and shows the amount of characters left.

Code

function _maxlength_add_maxlength_attributes(&$element, $settings, $suffix = '') {
  $element['#maxlength'] = isset($element['#maxlength']) ? $element['#maxlength'] : $settings['maxlength_js' . $suffix];
  $element['#maxlength_js'] = TRUE;
  $maxlength_js_label = !empty($settings['maxlength_js_label']) ? $settings['maxlength_js_label' . $suffix] : MAXLENGTH_DEFAULT_JS_LABEL;
  $maxlength_js_label = t($maxlength_js_label);
  $element['#attributes']['maxlength_js_label'] = array(
    $maxlength_js_label,
  );
}