I have both Organic Groups (og) and Bean enabled on a test site. I would like to be able to assign bean blocks to groups. I am able to add the Groups Audience field (provided by og) to my block type. However, if I create or edit a block and try to set the Groups Audience field, I get the following error:
EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. in EntityDrupalWrapper->set() (line 744 of .../sites/all/modules/contrib/entity/includes/entity.wrapper.inc).
If I leave the groups audience field set to "none", I am able to save the block.
Comments
Comment #1
indytechcook CreditAttribution: indytechcook commentedHey Paul,
The latest release contains some fixes to the Entity Metadata which might fix some of these issues. Can you please test?
Comment #2
acrollet CreditAttribution: acrollet commentedI had this problem, as described by OP. What I found is that the audience field assumes that it will get a numeric identifier. (See the schema for the etid column on the og_membership table). However, EntityMetadataWrapper's getIdentifier method returns the field specified by the 'name' entity key, if present. I modified the og code to always get the id, as opposed to the machine name. Patch attached, although it's probably more a starting point for discussion than a committable patch, given that getIdentifier() is used in several other places. That being said, this patch does allow one to save a new bean entity with an attached group audience field, and did not affect the ability to save a new node with a group audience field.
Comment #3
acrollet CreditAttribution: acrollet commentedupdated patch attached - this also modifies the load method of the OgBehaviorHandler class, allowing the selected audience to be seen when viewing a bean.
Comment #4
cecrs CreditAttribution: cecrs commentedRe-rolled against the latest dev.
Comment #5
Chris Burge CreditAttribution: Chris Burge commentedRe-rolled patch against the latest dev.
The 'includes/og.membership.inc' file has been reworked since the last patch was posted on this issue, and its respective hunk no longer applies. This hunk has been removed from this patch. The code in question was modified by #2231217: Prevent loading entity in \OgMembership::save() upon og_group(), which also employs the 'entity_load_single' function.
My testing indicates the patch continues to work as designed.
Comment #6
FrancescoQ CreditAttribution: FrancescoQ commentedHi, i've tried #5 and works for me. Now i'm testing, I tell you if something goes wrong! Thanks.
Comment #7
jaarong CreditAttribution: jaarong commented#5 appears to have worked for me as well.
Comment #8
HLopes CreditAttribution: HLopes commentedSame issue here, #5 fixed it.
Comment #9
Chris Burge CreditAttribution: Chris Burge commented