Pass bundle-specific field definition into formatter::isApplicable()

Created on 8 August 2024, 5 months ago
Updated 5 September 2024, 4 months ago

EntityCustomElementsDisplayEditForm calls isApplicable() to get the list (dropdowns) of applicable formatters for each field.

It passes in the base field definition to determine applicability. This turns out not to be enough information in many cases; the formatter needs bundle specific configuration/definition.

Proposed resolution

Not sure of exact technical details yet.

📌 Task
Status

Closed: works as designed

Version

3.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

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

Comments & Activities

  • Issue created by @roderik
  • Assigned to useernamee
  • 🇸🇮Slovenia useernamee Ljubljana
  • Assigned to roderik
  • 🇸🇮Slovenia useernamee Ljubljana

    [@roderik] are you sure it is the base field definition?

    The method Entity/EntityFieldManager::getFieldDefinitions is fetching bundle specific field definitions. (from \Drupal\custom_elements_ui\Form\EntityCustomElementsDisplayEditForm::getFieldDefinitions)

      /***
       * Allows all fields and not only whose display is configurable.
       *
       * @return \Drupal\Core\Field\FieldDefinitionInterface[]
       *   The array of field definitions
       */
      protected function getFieldDefinitions() {
        return $this->entityFieldManager->getFieldDefinitions($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle());
      }
    
  • Status changed to Postponed: needs info 4 months ago
  • 🇦🇹Austria fago Vienna
  • Status changed to Closed: works as designed 4 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    @useernamee thank you, you're right.

    Some fields pass a BaseFieldDefinition class, but some fields pass a FieldConfig class.

    (And all of these have a getSetting() that should contain whatever a specific formatter needs. I just needed to wade through some TypedData stuff and Plugin stuff, to be able to verify that my application code can work with this.)

    So this issue is 'works as designed'.

Production build 0.71.5 2024