Closed (fixed)
Project:
Computed Field
Version:
4.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Mar 2024 at 03:19 UTC
Updated:
19 Sep 2024 at 17:26 UTC
Jump to comment: Most recent
Comments
Comment #2
karlsheaI wonder if returning
target_typefromgetFieldDefinitionSettings()is a red herring? It looks likeEntityReferenceItemfrom core is returningtarget_typefromdefaultStorageSettings(), maybe there needs to be a way of influencing that from within a computed field plugin?Comment #3
karlsheaYes, looks like it, e.g.
EntityReferenceItem::storageSettingsSummary.$storage_definitionis \Drupal\computed_field\Field\FieldStorageDefinition, which in itscreate()is initializing the defaults for the field type, which is "node" target_type. It doesn't seems like there's any way to alter that either.Comment #4
karlsheaLooks like
ComputedFieldSettingsTraitis also conflating storage settings vs field settings as well which I don't think is hurting anything but I'm also not sure it's helping anything.Drupal\computed_field\Field\FieldStorageDefinition might need a way of talking to the computed field plugin to get field storage settings? Or possibly
getFieldStorageDefinition()in the ComputedField entity might do it?hook_entity_bundle_field_info_altercan't help because all you can do is set the settings on the storage definition which is just recreated each time it's accessed.Comment #6
karlsheaNope, it needs those settings there too.
Comment #7
karlsheaWould definitely appreciate a look at this, seems to have fixed the entity_reference issue for me! Media-specific field formatters are now appearing for my computed field.
It still feels like having combined settings for storage and the field is weird, but I don't know enough about field internals to know if that's normal or not 🤷🏻♂️
Comment #8
karlsheaLooks like this interacts with the cardinality patch, some of the media formatters look at the field storage definition cardinality in their
isApplicablemethod.When that patch is in this will also need to be added to
ComputedField::getFieldStorageDefinition():Comment #9
karlsheaRebased MR!11 on top of the work in #3350715: Computed field should specify the cardinality of the field
Comment #10
joachim commentedI've committed #3350715: Computed field should specify the cardinality of the field so this needs rebasing again.
Comment #11
karlsheaRebased!
Comment #12
joachim commentedMade a few tweaks.
Could you check to see if it still fixes the problem for you?
Comment #13
joachim commentedTested it locally and all works. Committed.
Thanks for reporting and working on this!
Comment #15
joachim commentedI'm going to file a follow-up for splitting the settings method into field settings & storage settings.
Comment #16
karlsheaThank you! It all appears to be working for me as well.
Comment #18
jonmcl commentedIf I am following along with this change, am I correct that this
needs to be changed to
Am I understanding this change correctly?
Comment #19
karlshea@jonmcl yes, that's correct! My computed media field has exactly the same code.