I have tried to display the flag with the computed field but I did not work..
I filled out the field Computed Code (PHP):
$entity_field[0]['value'] = "";
And Display Code (PHP):
$display_output = flag_create_link('product_comparison', $node->nid);
But at the node I get the errors:
* Notice: Undefined variable: node at function eval() (line 1 at file /home/111/sites/all/modules/computed_field/computed_field.module(318) : eval()'d code).
* Notice: Trying to get property of non-object at function eval() (line 1 at file /home/111/sites/all/modules/computed_field/computed_field.module(318) : eval()'d code).
And Flag link is displayed, but does not work.
Comments
Comment #1
webroru commentedI noticed if instead of "$ node-> nid" indicate clearly the number node (for example
), the errors disappear and flags start working for this node.
Comment #2
webroru commentedI got it!
To get 'nid' in the computed field is necessary to do: $entity->nid;
Comment #3
webroru commentedComment #4
mgriebe commentedThat you can use computed field to attach a create flag link to an entity should be added to the documentation.