You are here

function nodereference_node_import_values_alter in Node import 6

Implementation of hook_node_import_values_alter().

File

supported/cck/nodereference.inc, line 41
Support file for the CCK Node reference module.

Code

function nodereference_node_import_values_alter(&$values, $type, $defaults, $options, $fields, $preview) {
  foreach (node_import_cck_fields($type, 'nodereference') as $fieldname => $fieldinfo) {
    if ($fieldinfo['widget']['type'] == 'nodereference_autocomplete') {
      foreach ($values[$fieldname] as $i => $value) {

        // This is just braindead - because of some wrapper, the value
        // needs to be:
        // array(0 => array('nid' => array('nid' => 'name')))
        // instead of:
        // array(0 => array('nid' => 'name')).
        $values[$fieldname][$i]['nid'] = array(
          'nid' => $values[$fieldname][$i]['nid'],
        );
      }
    }
  }
}