A small PHP tweak to allow for lomger autocomplete entries in Drupal

PHOTO EMBED

Tue Apr 06 2021 13:12:16 GMT+0000 (UTC)

Saved by @SirClickalot #php

<?php

use Drupal\comment\CommentInterface;

function custom_drupal_overrides_field_widget_form_alter(&$element, &$form_state, $context) {
    if ($context['widget']->getPluginId() == 'entity_reference_autocomplete') {
      if ($element['target_id']['#maxlength'] == 1024) {
        $element['target_id']['#maxlength'] = 3072;
      }
    }
  if ($context['widget']->getPluginId() == 'entity_reference_tree') {
    if ($element['target_id']['#maxlength'] == 1024) {
      $element['target_id']['#maxlength'] = 3072;
    }
  }
}
content_copyCOPY