Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Should allow integration with Search API and other entity API integrations.
Comment | File | Size | Author |
---|---|---|---|
#40 | 2041531-40-entity-api-support.patch | 6.56 KB | mvdve |
#23 | 2041531-23-entity-api-support.patch | 5.72 KB | dobe |
#15 | 2041531-15-entity-api-support.patch | 5.98 KB | Jelle_S |
#13 | 2041531-13-entity-api-support.patch | 3.71 KB | e0ipso |
Comments
Comment #1
ar-jan CreditAttribution: ar-jan commentedWould this also address using (entity?) tokens or should that be a separate issue? Currently if you use a multifield's token (e.g. with auto_entitylabel) you get the serialized data.
Comment #2
byung CreditAttribution: byung commentedThanks Dave for picking this back up. Search indexing would be a bigger help than views issue for me.
Comment #3
mihai_brb CreditAttribution: mihai_brb commentedI was playing with multifield and entity property info. After adding the multifield fields as multifield type the sub-fields are availabe in Search API. However the values are not picked up, and therefor not indexed. I guess this is because the sub-fields require custom getters? Or how would one quickly implement this?
Thanks,
Mihai
Comment #4
Dave ReidComment #5
e0ipsoThis will allow you to do something like:
This patch only adds get support. So feel free to review it and set it to Needs work for set support.
Comment #6
deviantintegral CreditAttribution: deviantintegral commented"Set the property type based on the targe type."
Missing t on target.
The patch needs to be rerolled with --relative.
I was *sure* that there was a way to do this within a class instead of a function callback (like EntityDefaultMetadataController). If so, that's a better way to go since it means code is only loaded if it's needed. But, I can't find it now, so perhaps it does have to be in the module directly.
Comment #7
e0ipsoArgh, I always forgot about the
--relative
.Rerolled.
Comment #8
e0ipsoThis update addresses a weird cache issue.
Comment #9
Dave ReidShould this run field_access() instead?
Comment #10
e0ipso@Dave Reid do you mean something like this?
Comment #11
e0ipsoCatch the case when there is no entity id.
Comment #12
e0ipsoComment #13
e0ipsoUpdated patch again.
Comment #14
becw CreditAttribution: becw commentedI'm using this with Search API, and I'm finding that some multifield subfields are not available to add to the Search API index. When I index my content, I get errors like:
I'll look into this and try to provide some more details and a fix, but it might be a week or two before I can work on this again.
Comment #15
Jelle_SPatch provides full entity property API integration. Should also fix the errors mentioned above.
Comment #16
becw CreditAttribution: becw commentedIt turns out that my array_flip() errors were not coming from multifield itself, and the subfields are available, they're just hard to find (they're nested a few layers deep). Both patch 13 and patch 15 work for me in that they make multifield data available to Search API indexes. The significance of the differences between the two patches is not clear.
Comment #17
jOksanen CreditAttribution: jOksanen commentedPatch 15 tested and works for me as it should. Was able to use it as a facet as well.
Marking as RTBC.
Comment #18
odegard CreditAttribution: odegard commentedHaven't looked at the code, but can confirm that it works as intended. I'm using it in a module where I iterate over subfields to get values.
Comment #19
mkinnan CreditAttribution: mkinnan commentedI reported on an issue here:
https://www.drupal.org/node/2392713#comment-9551519
that appears to be related to the multifield_access_callback function from patch #15. Unfortunately, I don't know enough about node access in Drupal to be able to troubleshoot
Comment #20
edmund.kwok CreditAttribution: edmund.kwok commented+1 with #15. Able to iterate perfectly with unlimited values multifield.
I can't get the setter working though. Anyone has any ideas on the syntax for set to work? Tried a few permutations of this but still no joy.
Comment #21
dobe CreditAttribution: dobe commentedI am with #20. Cannot get these values to save programmatically.
Comment #22
dobe CreditAttribution: dobe commentedComment #23
dobe CreditAttribution: dobe commentedHere is a patch that removed some things from the setter callback. I could not make heads or tails as to why it was there. But after I removed it.
Then
Comment #24
dobe CreditAttribution: dobe commentedComment #25
kopeboy CreditAttribution: kopeboy commented(not a developer)
Does this mean that we cannot set subfield values with Rules?
..or should I open a new issue?
Comment #26
mparker17The patch in #23 worked for me: I can now interact with multifields using entity metadata wrappers.
Comment #27
Andrej Galuf CreditAttribution: Andrej Galuf commentedWe have multiple multifields on the node. For some reason, on some nodes the entity wrapper pulls completely wrong multifield data.
Accessing it traditionally returns the real value:
$start returns 3.
Accessing it through wrapper, though:
$test === $testToo
We have 8 different multifields, of which these two are the only ones on this node bundle, so I am assuming the wrapper has problems distinguishing between various multifields. Note that this only happened on those nodes that had values in the second multifield and that when I deleted / re-added the field, the bug went away.
Comment #28
filip_p CreditAttribution: filip_p commentedAny news on implementing this in an update to Multifield? I could REALLY use this feature but I'm not familiar with patching.
Comment #29
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commented#23 seems to work.
Comment #30
ademarco CreditAttribution: ademarco at Nuvole commented#23 works for me too.
Comment #31
bkat CreditAttribution: bkat commentedI'm trying to use editablefields module on multifield subfields to allow editing of elements on the parent nodes view page or within views.
I have things pretty much working except that then editablefields calls entity_save() nothing actually gets written to the database.
Should this patch allow us to save a multifield entity outside of saving the host entity?
entity_save is a no op because we don't have a save method on the entity, no "save callback" is defined for the entity info and MultifieldEntityController does not implement EntityAPIControllerInterface.
As an experiment, I tried changing the controller to extend EntityAPIController but that fails because the base table is "multifield" and what we really want to write to is field_data_field_$multifield.
If this is out of scope for this patch, I'll submit a new issue.
Comment #32
Sebastien M. CreditAttribution: Sebastien M. as a volunteer and at Actualys commentedworks for us too.
could you generate a new release with, at least, this fix ?
many thanks for the work
Comment #33
vasikeI can confirm RTBC.
Comment #34
vasikei used the solution here for a Multifield integration with Search API attachments : #2670994: Files attached to multifield fields are not indexed
Comment #35
Derimagia CreditAttribution: Derimagia at Mindgrub Technologies commentedThis was only implemented for the field itself, for sub-fields this needs work.
$wrapper->field_multifield->field_textfield->value(); and $wrapper->field_multifield->field_textfield->set('Test') should work
Comment #36
Kris77 CreditAttribution: Kris77 commentedIt would be very useful to loop through multifield values and carry out actions with the subfields in Rules module.
Comment #37
MustangGB CreditAttribution: MustangGB commentedRan into I believe the same problem as #35.
Essentially I'm trying to get Multifield to work with Services Entity API
The JSON I'm sending is something like this:
And these are the changes to #23 I made to get it working, I didn't bother to roll a patch though as probably something needs to be done to remove the hardcoded
['value']
:Comment #38
abarrios CreditAttribution: abarrios commentedIn order to complete this patch, the "MultifieldEntityController" class should implement "EntityAPIControllerInterface" from the entity module. This patch doesn't implement that, it just extends from core "DrupalDefaultEntityController".
The current status reports errors in different parts of a normal workflow with entity module enabled because this is not implemented and it should be because that is declared in the hook_entity_info().
Some error samples that you might encounter using this patch:
Comment #39
mvdve CreditAttribution: mvdve commentedI have an issue where the entity translation is not loaded. Only the original language is selected within the getter callback. The result is that the wrong row/id will be loaded (the one from the original language).
I updated the patch but it replicates the fallback mechanism of the entity_translation module which doesn't look like the right way to handle this.
It would be logical for the getLanguage() method to return the current language but is selects the original language.
Please let me now when there is a nicer way in handling this. After this has been resolved, i will implement the EntityAPIControllerInterface interface to complete the patch.
Comment #40
mvdve CreditAttribution: mvdve commentedImproved patch. The language property should be used when it is set. For example when the entity is created with migrate/feeds.