I have created a computed field that is used to sort an event calendar into regions with views. It is a pretty simple IF...ELSEIF...ELSE thing. This was an addon to existing site structure, so I used VBO to resave the existing nodes to populate the new computed field into the database. The hardest part was figuring out what the code for the location module's province code in the array was...

Anyhow, the trouble was that after I implemented it on the live site, this one event has the wrong value. The second else value is stored when it should have had been true for the first IF statement... I figure it is the location data, so I update, change it, delete and reenter. Nothing, no change to the computed. So then I think it must be that if my field has an existing value, that I have done something to make it not change. Back on my dev site, changed the computed field to have different text to be stored in the database of the last ELSE. When I updated the node, bingo it's fixed! But I don't know why and fear it will come back.

Any ideas on what caused this? Here is my computed field code:

<?php
$prov = $node->locations[0]['province'];
if (!$node->nid) {
node_save($node);
}
if ( $prov == 'CO' ) {
   $node_field[0]['value'] = t( 'Colorado' );
} elseif ( $prov == 'IL' || $prov == 'IA' || $prov == 'IN' || $prov == 'WI' ) {
   $node_field[0]['value'] = t( 'Illinois' );
} else {
   $node_field[0]['value'] = t( 'National ' );
}
?>

Comments

mmjvb’s picture

Status: Active » Closed (outdated)