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.
not sure what the code for this is doing to provide $entity for creating the computed value; but:
i have an OG ref field which is called og_group_ref, when i look at the $entity that is available to create my field value with; although this field is listed in the "entity" it is empty, whereas if i do this:
$entity = current(entity_load('node', array($entity->nid)));
then i get the full entity and the OG ref value is available.
Comments
Comment #1
grn CreditAttribution: grn commentedThis is great, how did you figure come up with that that?
I used your $entity load and I was able to use computed code to display the node id(nid) and the first comment id(cid) with:
$entity->nid and $entity->cid
What I am trying to do, is to show user points on the comments by using a computed comment field. I will need the authors user id(uid) on each comment to do that.
I thought I could load each comment from computed field by doing something like this:
But it did not work.
Any hints?
Thanks.
GrN.dk
Comment #2
liquidcms CreditAttribution: liquidcms commentedmy solution above is not correct.
doing the entity_load loads the current stored entity; this will not include field values which have been changed on this submit.
so the issue remains in how/when computed field is calculating its field value since in this case; the og value has not yet been added to the pre-saved entity object
would be better if the computed field function to calculate its value had access to the $form_state values
Comment #3
liquidcms CreditAttribution: liquidcms commentedpossibly not the most secure solution; but of course $_POST does have the new field values.
Comment #4
grn CreditAttribution: grn commentedThanks for then info.
I have actually given up on getting author specific data on the comments, but will still keep an eye out for a good soluiton.