diff -urp cck-raw/modules/nodereference/nodereference.module cck/modules/nodereference/nodereference.module --- cck/modules/nodereference/nodereference.module 2009-04-29 15:51:53.000000000 -0500 +++ cck/modules/nodereference/nodereference.module 2009-06-12 10:13:28.659040500 -0500 @@ -679,7 +679,10 @@ function nodereference_autocomplete_vali // Explicit [nid:n]. list(, $title, $nid) = $matches; if (!empty($title) && ($n = node_load($nid)) && $title != $n->title) { - form_error($element[$field_key], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label'])))); + $potential_references = _nodereference_potential_references($field, $title, 'equals', NULL, 10); + if (!empty($title) && ($potential_references[$nid]['title'] != $title)) { + form_error($element[$field_key], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label'])))); + } } } else { @@ -785,16 +788,24 @@ function _nodereference_potential_refere // We might also need to check if there's an argument, and set *its* style_plugin as well. $view->display_handler->set_option('style_plugin', 'content_php_array_autocomplete'); $view->display_handler->set_option('row_plugin', 'fields'); + + $fields = $view->display['default']->display_options['fields']; + foreach ($fields as $field) { + if (!$field['exclude']) { + $referenced_field = $field; + break; + } + } // Used in content_plugin_style_php_array::render(), to get // the 'field' to be used as title. - $view->display_handler->set_option('content_title_field', 'title'); + $view->display_handler->set_option('content_title_field', $referenced_field['id']); // Additional options to let content_plugin_display_references::query() // narrow the results. $options = array( - 'table' => 'node', - 'field_string' => 'title', - 'string' => $string, + 'table' => $referenced_field['table'], // Table to search + 'field_string' => $referenced_field['field'], // Field to search + 'string' => $string, // Search string 'match' => $match, 'field_id' => 'nid', 'ids' => $ids, @@ -805,8 +816,9 @@ function _nodereference_potential_refere // should be moved to content_plugin_display_references // Limit result set size. - $limit = isset($limit) ? $limit : 0; - $view->display_handler->set_option('items_per_page', $limit); + if (isset($limit)) { + $view->display_handler->set_option('items_per_page', $limit); + } // Get arguments for the view. if (!empty($field['advanced_view_args'])) {