You are here

function maxlength_element_info_alter in Maxlength 8

Same name and namespace in other branches
  1. 7.3 maxlength.module \maxlength_element_info_alter()

Implements hook_element_info_alter().

@todo: Check if all them work.

Parameters

$cache:

File

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

Code

function maxlength_element_info_alter(&$cache) {

  // Add prerender functions to textareas and text fields.
  $cache['textfield']['#pre_render'][] = [
    MaxLengthCallbacks::class,
    'maxlengthPreRender',
  ];
  $cache['textarea']['#pre_render'][] = [
    MaxLengthCallbacks::class,
    'maxlengthPreRender',
  ];
  $cache['textarea']['#process'][] = [
    MaxLengthCallbacks::class,
    'processElement',
  ];
  $cache['text_format']['#pre_render'][] = [
    MaxLengthCallbacks::class,
    'maxlengthPreRender',
  ];
  $cache['text_format']['#process'][] = [
    MaxLengthCallbacks::class,
    'processElement',
  ];
}