Increase maximum amount of characters for entity reference field (tag style)

I have a Drupal 9 installation running Commerce 2. My products use a taxonomy entity reference field (tag style). There’s one products category, where I need to have more references in the tag input field than currently allowed (1024 characters).

I looked it up and found a similar post where someone suggested to write a module to increase the maximum input value like so:

function MODULE_field_widget_form_alter(&$element, &$form_state, $context) {

  if ($context['widget']->getPluginId() == 'entity_reference_autocomplete_tags') {
    if ($element['target_id']['#maxlength'] == 1024) {
      $element['target_id']['#maxlength'] = 3072;
    }
  }
}

So I did that, but it still doesn’t let me input more than 1024 characters. Any help would be appreciated. Thank you!


Go to Source of this post
Author Of this post: Berry Dingle
Title Of post: Increase maximum amount of characters for entity reference field (tag style)
Author Link: {authorlink}