Add support for bundle specific configuration

Created on 20 February 2024, 9 months ago
Updated 7 March 2024, 8 months ago

Problem/Motivation

It would be good to support field per bundle configuration to take advantage of specific instances. For example, Photoswipe requires the bundle for certain settings such as target_bundle. This enables the selection of a specific image field on the target media entity.

Currently this is not possible with fieldblock.

There's a comment in FieldBlock.php:

   * A FieldBlock works on an entity type across bundles, and thus only has
   * access to field storage definitions. In order to be able to use formatters,
   * we create a generic field definition out of that storage definition.

Having access to the bundle would enable access to the specific FieldConfig rather than a generic field definition.

e.g.

$bundle_fields = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle);

Steps to reproduce

  1. Install fieldblock and photoswipe.
  2. Add a media reference field to a content type
  3. Place a content block in a region, selecting the reference field
  4. Under "Formatter" select "Photoswipe"
  5. Under "Formatter settings" the select list for "Image field of the referenced entity" will be empty.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇦🇺Australia imclean Tasmania

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

Merge Requests

Comments & Activities

  • Issue created by @imclean
  • 🇦🇺Australia imclean Tasmania

    I've created a proof of concept which lists relevant fields separately per bundle as well as an "all bundles" option, which is the default and works the same as it does now without any changes to config.

    Before I refine the code for sharing I'd like some feedback on the approach. This is how the field list would present.

  • Merge request !4Add support for bundle specific fields. → (Open) created by imclean
  • Status changed to Needs review 9 months ago
  • 🇦🇺Australia imclean Tasmania
  • 🇦🇺Australia imclean Tasmania

    I'm looking at adding support for third party settings. I think this only makes sense per instance so can probably be included here as well.

  • 🇦🇺Australia imclean Tasmania

    I've added support for third party settings. To test, enable Photoswipe's submodule Photoswipe Dynamic Caption and configure.

Production build 0.71.5 2024