- Issue created by @karlshea
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
I wonder if returning
target_type
fromgetFieldDefinitionSettings()
is a red herring? It looks likeEntityReferenceItem
from core is returningtarget_type
fromdefaultStorageSettings()
, maybe there needs to be a way of influencing that from within a computed field plugin? - πΊπΈUnited States karlshea Minneapolis πΊπΈ
Yes, looks like it, e.g.
EntityReferenceItem::storageSettingsSummary
.$storage_definition
is \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. - πΊπΈUnited States karlshea Minneapolis πΊπΈ
Looks like
ComputedFieldSettingsTrait
is 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_alter
can't help because all you can do is set the settings on the storage definition which is just recreated each time it's accessed. - Merge request !11Allow plugin to set storage settings / Donβt conflate field settings and storage settings β (Open) created by karlshea
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
Looks like ComputedFieldSettingsTrait is 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.
Nope, it needs those settings there too.
- Status changed to Needs review
8 months ago 5:12am 26 March 2024 - πΊπΈUnited States karlshea Minneapolis πΊπΈ
Would definitely appreciate a look at this, seems to have fixed the entity_reference issue for me!
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
Looks like this interacts with the cardinality patch, some of the media formatters look at the field storage definition cardinality in their
isApplicable
method.When that patch is in this will also need to be added to
ComputedField::getFieldStorageDefinition()
:// Set cardinality $definition->setCardinality($plugin->getFieldCardinality());
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
Rebased MR!11 on top of the work in π Computed field should specify the cardinality of the field Fixed
- Status changed to Needs work
6 months ago 4:32pm 13 May 2024 - π¬π§United Kingdom joachim
I've committed π Computed field should specify the cardinality of the field Fixed so this needs rebasing again.
- Status changed to Needs review
6 months ago 4:57pm 13 May 2024 - π¬π§United Kingdom joachim
Made a few tweaks.
Could you check to see if it still fixes the problem for you?
- Status changed to Fixed
6 months ago 10:06am 18 May 2024 - π¬π§United Kingdom joachim
Tested it locally and all works. Committed.
Thanks for reporting and working on this!
-
joachim β
committed 2177ee1b on 4.0.x
Issue #3436047 by KarlShea, joachim: Field storage doesnβt get settings...
-
joachim β
committed 2177ee1b on 4.0.x
- π¬π§United Kingdom joachim
I'm going to file a follow-up for splitting the settings method into field settings & storage settings.
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
Thank you! It all appears to be working for me as well.
Automatically closed - issue fixed for 2 weeks with no activity.
- πΊπΈUnited States JonMcL Brooklyn, NY
If I am following along with this change, am I correct that this
public function getFieldDefinitionSettings(): array { return [ 'target_type' => 'media', 'handler' => 'default:media', 'handler_settings' => [ 'target_bundles' => [ 'image', ], ], ]; }
needs to be changed to
public function getStorageDefinitionSettings(): array { return [ 'target_type' => 'media', ]; } public function getFieldDefinitionSettings(): array { return [ 'handler' => 'default:media', 'handler_settings' => [ 'target_bundles' => [ 'image', ], ], ]; }
Am I understanding this change correctly?
- πΊπΈUnited States karlshea Minneapolis πΊπΈ
@jonmcl yes, that's correct! My computed media field has exactly the same code.