I have a pretty simple action that takes values of two fields, then values of the fields from another node (added and available via another action) - as ranges, then compares the two field values against these ranges, assigns integers matching given ranges to two temp vars. Then these vars are compared and the one with the greater value should be returned as the value in the array for this field. But I look at debug and have a NULL in this array - the values do not get passed. Am I doing something wrong with the temp vars? This should be very simple.
Here is the code:
<?php
// get the first numeric value
$sys = $node->field_bp_reading_s[0]['value'];
// get the second numeric value
$dia = $node->field_bp_reading_d[0]['value'];
// get the values for "ranges" for the first value
$bp_sys_r_lower = $bp_node_zones->field_bp_sys_r_lower[0]['value'];
$bp_sys_r_upper = $bp_node_zones->field_bp_sys_r_upper[0]['value'];
$bp_sys_g_lower = $bp_node_zones->field_bp_sys_g_lower[0]['value'];
$bp_sys_g_upper = $bp_node_zones->field_bp_sys_g_upper[0]['value'];
// get the values for "ranges" for the second value
$bp_dia_r_lower = $bp_node_zones->field_bp_dia_r_lower[0]['value'];
$bp_dia_r_upper = $bp_node_zones->field_bp_dia_r_upper[0]['value'];
$bp_dia_g_lower = $bp_node_zones->field_bp_dia_g_lower[0]['value'];
$bp_dia_g_upper = $bp_node_zones->field_bp_dia_g_upper[0]['value'];
// now compare the first value to its ranges
// give an integer value to the temp $s variable based on the range match
// if I right here I return the array with this integer as straight value instead of using $s, it assigns fine
// but this is not what is needed. I still need to run another comparison before assigning value,
// so need to use a temp var for storage of this value.
if ( $sys > $bp_sys_r_upper ) {
$s = 178; }
elseif ( $sys <= $bp_sys_r_upper && $sys >= $bp_sys_r_lower ) {
$s = 179; }
elseif (( $sys < $bp_sys_r_lower && $sys > $bp_sys_g_upper ) {
$s = 180; }
elseif ( $sys <= $bp_sys_g_upper && $sys >= $bp_sys_g_lower ) {
$s = 181; }
elseif ( $sys < $bp_sys_g_lower ) {
$s = 182; }
// comparing the second value against its ranges
// based on this, an integer value should assign to another temp variable $d
if ( $dia > $bp_dia_r_upper ) {
$d = 178; }
elseif ( $dia <= $bp_dia_r_upper && $dia >= bp_dia_r_lower ) {
$d = 179; }
elseif ( $dia < $bp_dia_r_lower && $dia > $bp_dia_g_upper ) {
$d = 180; }
elseif ( $dia <= $bp_dia_g_upper && $dia >= $bp_dia_g_lower ) {
$d = 181; }
elseif ( $dia < $bp_dia_g_lower ) {
$d = 182; }
// here a simple comparison should be done
// based on the result, we should return the needed integer to the array
// instead the array comes back with NULL
if ( $s >= $d ) {
return array(0 => array('value' => $s),); }
else {
return array(0 => array('value' => $d),); }
?>Everything looks clean to me and everything would work if I did not have to use $d or $s and just returned value in the else/if statements. But I need to compare the values before returning them. Is there a problem with temp vars in Rules or am I missing something? Thanks!