Pass field entity context into the field plugin build

Created on 6 December 2023, about 1 year ago
Updated 9 April 2024, 8 months ago

ExtraFieldTypePlugins do not have the context of their parent EntityExtraField entity. This is a problem specifically with the block plugin, which expects a unique ID passed into the #id value. That ID gets used for both the HTML ID of the block as well as the theme template suggestions available to themers. Currently in the block plugin, the #id gets set to str_replace(':', '-', $block->getPluginId()) and the hypen in the string replacement throws an error (seen in the template suggestions HTML comment). If the plugins had the field entity context, we could appropriately set the ID to the value typed in by the site builder, same as the default blocks work: '#id' => $field_entity->name(). Passing this value in would be easy enough. EntityExtraField.php on line 330 could be something like this: 'content' => $field_type_plugin->build($entity, $display, $this). This would pass in the entity for context, and then display plugins could leverage that as needed.

πŸ› Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jnettik Denver, CO

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

Comments & Activities

  • Issue created by @jnettik
  • First commit to issue fork.
  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States COBadger
  • πŸ‡ΊπŸ‡ΈUnited States droath

    @jnettik

    I have made the changes as outlined so that any entity extra field plugin type can utilize the data attached to the extra field object. I am concerned that this patch might cause issues for existing sites that rely on the block ID instead of using the entity field name. Are you willing to test this patch to ensure it works for your problem?

  • Status changed to Postponed: needs info 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States droath
Production build 0.71.5 2024