You are here

public static function MaxLengthCallbacks::processElement in Maxlength 8

Process handler for the form elements that can have maxlength attribute.

Parameters

array $element: The render array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

Return value

array The processed render array.

File

src/MaxLengthCallbacks.php, line 51

Class

MaxLengthCallbacks
Trusted render callbacks.

Namespace

Drupal\maxlength

Code

public static function processElement($element, FormStateInterface $form_state) {
  if (isset($element['#attributes']['#maxlength_js_enforce']) && $element['#attributes']['#maxlength_js_enforce']) {
    $element['#attributes']['class'][] = 'maxlength_js_enforce';
  }
  if (isset($element['#attributes']['#maxlength_js_truncate_html']) && $element['#attributes']['#maxlength_js_truncate_html']) {
    $element['#attributes']['class'][] = 'maxlength_js_truncate_html';
  }
  return $element;
}