Active
Project:
Computed Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Jan 2012 at 16:20 UTC
Updated:
23 Aug 2012 at 06:52 UTC
The following code produces an exception.
$node = node_load($nid);
$wrapper = entity_metadata_wrapper('node', $node);
$field_value = $wrapper->field_my_computed_field->value();
EntityMetadataWrapperException: Unknown data property field_my_computed_field. in EntityStructureWrapper->getPropertyInfo()
(line 339 of .../sites/all/modules/entity/includes/entity.wrapper.inc).
However, other fields created using UI can be accessed using this method.
The Entity module become popular, it is better to add support for it.
Comments
Comment #1
skipyT commentedHi,
I think the patch file from: http://drupal.org/node/1514848#comment-6049526 is fixing your issue also.
I made the modification to support the computed fields in the search api module, but it is the same fix.
Comment #2
BParticle commentedHi,
Not sure if this is the right thread to post to, but as I'm using entity_metadata_wrapper maybe it is related. I am desperately trying to do simple calculations with some fields inside a field collection entity.
This is the code in the computed field area, I'm adding up the values of field_bar inside the collection field_student:
Although it's not perfect (due to undefined index errors for empty values), it works as intended when loaded from the node template. When I use the exact same code in the computed field however, there is no returned value. Is entity_metadata_wrapper actually supported in this way, is my code wrong? (I applied the patch on http://drupal.org/node/1514848#comment-6049526)
Any help most appreciated,
BP
Comment #3
skipyT commentedI don't think you can use entity metadata wrapper there, because the node is not fully loaded yet I think, if your computed field is on a node.
Perhaps your field is not loaded yet, that's why the exception.
Comment #4
BParticle commentedThat makes sense, but then I don't know how to use this module.
Am I supposed to add a computed field to a different entity, using the field information of a target node? That seems rather far fetched. I thought the whole point of the module was that it enables you to make calculations with the information given by the user in the same form, on the same entity...
Comment #5
BParticle commented@skipyT Just had a look at the initial code of this thread. It seems to be a different matter altogether so I will file a support request elsewhere. Thank you for answering.