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

grn’s picture

This 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:

$comment = current(entity_load('comment', array($comment->cid)));
print $comment->uid; //not actually printed like this in the computed code interface.

But it did not work.

Any hints?

Thanks.

GrN.dk

liquidcms’s picture

my 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

liquidcms’s picture

possibly not the most secure solution; but of course $_POST does have the new field values.

grn’s picture

Thanks 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.