Add entity object to widget

Created on 16 January 2025, 3 days ago

The TagifyEntityReferenceAutocompleteWidget doesn't add entity object to element data set. For example, EntityReferenceAutocompleteWidget does it like that:

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  ...
  $entity = $items->getEntity();

  // Append the entity if it is already created.
  if (!$entity->isNew()) {
    $selection_settings['entity'] = $entity;
  }
...

Proposed solution: Add entity object to EntityReferenceAutocompleteWidget as well, so entity can be fetched in other places, like that:

$configuration = $this->getConfiguration();
$channel = $configuration['entity'];

For example, it can be useful in custom entity reference selection plugin which can be attached to field with Tagify widget.

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇺🇦Ukraine oleksandr.s

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024