How to recalculate fields with view of views and editable fileds?
I am trying to do the following, but doesn't work in the way I did:
Node type 'input' has a field 'input1' and a node reference field with multiple values set to all item nodes.
Node type 'item' has a field 'unitprice', node reference field to 'input' and a calculated field that muliplies 'input1' * 'unitprice'.
With the 'view of views', 'viewfield' and the 'editable fields' modules I put a table view of all items and a full node view of 'input' (with field 'input1' editable) inside the node type 'input' itself using the appropriate arguments. To do this I followed mainly the description of the example for the view of views module: http://drupal.org/project/view_of_views
The display of the views inside node 'input' is actually working, but the recalculation of the computed fields in the items view not, if I change the value of the editable field 'input1'. The value 'input1' which is displayed in the node updates correctly.
So I guess it's just a matter of getting the calculated fields to recalculate. In the view of views module description is mentioned:
Some bad things to note - the computed field runs the view in the display code - otherwise it wont update when a node that is not this node is updated. If you want to make a calculation based on a calculated field, you need to re-calculate it all.
In that description is also referred to 'Computing a field from a view': http://drupal.org/node/180013 where this code is shown:
$view = views_get_view('YOURVIEWNAME');
$info=views_build_view('items', $view, array($node->nid), false, false);
$total=0;
//drupal_set_message(serialize($info));
foreach ($info['items'] as $item) {
$total+=$item->YOUR_FIELD_USE_THE_DEBUG_MESSAGE_ABOVE_TO_FIND_IT;
}
$node_field[0]['value']=$total;How I understand it, the code
$view = views_get_view('YOURVIEWNAME');
$info=views_build_view('items', $view, array($node->nid), false, false);
rebuilds the view and gets the calculated fields to recalculate.
Now:
1. Did I get this right?
2. Where and how do I need to use the above code to get the computed fields updated?
3. If I didn't get this right, how does it work otherwise?
Tips and help on that would be very much appreciated as I'm stuggeling around with this since days.
