Using hook_node_presave to auto-select a reference field from a field list selection I'm trying to use hook_node_presave to select a value in a term reference field based on a selection a user makes in a field list field. The term reference field is hidden from the user. The code I'm working with is problemmatic in at least two ways:

1) I'm not sure I'm referencing the correct theme in my function header because the dpm() is not outputting anything. But it's in the administrative theme 'seven' that this form is running so I assume that's right.

2) I'm getting errors when I run this code saying 'syntax error, unexpected ||' wherever I have those. Am I not using the correct syntax for OR operators? It seems fine to me. I tried OR in place of || and got the same errors.

Here's the code I'm working with:

function seven_node_presave($node) {
    $field_type = $form['field_type']['und']['#options'];
    dpm($field_type);
    if (($field_type == 4) || ($field_type == 5)) || ($field_type == 7) || 
($field_type == 6)) {
        $form['field_icon']['und']['#options'][]= '2';
    }
    elseif (($field_type == '9') || ($field_type == '98')) || ($field_type == '8')) {
        $form['field_icon']['und']['#options'][]= '6';
    }
    elseif (($field_type == '3') || ($field_type == '1')) || ($field_type == '2')) {
        $form['field_icon']['und']['#options'][]= '1';
    }
}


Note 1: the numbers being compared to (ex: $field_type == 4) are the 'keys' for those fields, not the actual text the user would select.

Note 2: I'm running this from a module called grouphideandselect, not from template.php...maybe that's my problem?
As Darvanen said above, the function name is wrong, replace HOOK by the module's name in HOOK_node_presave().
About the || operators, you could use in_array instead or a single associative array:

function grouphideandselect_node_presave($node) {
    $field_type = $form['field_type']['und']['#options'];
    dpm($field_type);

    $field_type_to_icon = array(
      1 =&gt; 1,
      2 =&gt; 1,
      3 =&gt; 1,
      4 =&gt; 2,
      5 =&gt; 2,
      7 =&gt; 2,
      8 =&gt; 6,
      9 =&gt; 6,
      98 =&gt; 6,
    );

    if (isset($field_type_to_icon[$field_type])) {
      $form['field_icon']['und']['#options'][] = $field_type_to_icon[$field_type];
    }
}


EDIT: from another question of yours I see that you already tried renaming the function to grouphideandselect_node_presave. You need to make sure that:
- the function's name is right
- the module is enabled
- you cleared Drupal's cache afterwards