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
- Install fieldblock and photoswipe.
- Add a media reference field to a content type
- Place a content block in a region, selecting the reference field
- Under "Formatter" select "Photoswipe"
- 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
Comment | File | Size | Author |
---|
Issue fork fieldblock-3422529
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
imclean CreditAttribution: imclean commentedI'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.
Comment #4
imclean CreditAttribution: imclean commentedComment #5
imclean CreditAttribution: imclean commentedI'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.
Comment #6
imclean CreditAttribution: imclean commentedI've added support for third party settings. To test, enable Photoswipe's submodule Photoswipe Dynamic Caption and configure.