<?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; } } }