Accessing other field values before save?
sensoria - July 3, 2009 - 17:42
| Project: | Computed Field |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I've created a content type with a computed field in it, which gets saved to a table. I need to access the selected values in two user selected dropdown menus prior to saving, so that I can know which values the computed field should act on.
Is there some way to access the values prior to them being saved to the database?

#1
To clarify, the two fields I need to access are node reference fields.
#2
subscribing...
#3
Sensoria,
I know of no other way than to write a custom function in a custom module to do this. Are you up for that?
Also. can you walk me through the flow? Which fields are we talking about? What gets computed? What is the logic?
- Doug Vann
- www.dougvann.com
- www.twitter.com/dougvann
#4
The following example almost works but the problem with the node reference field persists:
//code should get call for tender content type field_tender_cost_weight for the selected call for tender node reference
// Set some vars
// TenderID
// PROBLEM: User generated value, cannot be accessed via PHP, returns a null value
$tender_nr_id = $node->field_openedbid_tender_nr[0]['value'];
//$tender_nr_id = '148'; when this line is used computed field works
// Get data from matching call for tender
$sql = "SELECT field_tender_cost_weight_value AS cost_weight FROM {content_type_tender} WHERE nid = $tender_nr_id";
$result = db_query($sql);
$result = db_fetch_object($result);
$cost_weight = ($result->cost_weight);
$node_field[0]['value'] = $cost_weight;
When I call the specific node number the field computes.* When I use the code to grab the node ID from the node reference field nothing calculates.
*Another problem... the field appears to only compute on the first save. I changed the value in the referenced node, the computed field did not update when I edited the node holding the computed field.
Thanks, Bob