The autocomplete fallback behavior doesn't activate the ajax behavior. It is a normal text field not an autocomplete textfield.

Comments

Adam S’s picture

In function theme_textfield() in includes/form.inc line 3633 the autocomplete path was not validating with drupal_valid_path.

I changed the node_reference_field_widget_form function to reflect the autocomplete text widget in the node_reference module of References by adding . $field['field_name']

'#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $instance['entity_type'] . '/' . $instance['bundle'] . '/' . $field['field_name'],

The form field widget now worked but wasn't returning any results. I stepped through the code but can't understand the query of _node_reference_potential_references_standard($field, $options) in the node_reference.module line 746.

Knowing that this is beyond me I cleared the cache, then I cleared the cache again, then just cleared the menu cache, then the whole cached to make sure.

Well, I tested the using the autocomplete textfield and returned to the node reference URL widget which oddly enough works just fine. Cleared the cache -- mostly out of habit -- and it still works.

I don't know what the problem is. I hope this information helps solve it.

notasheep’s picture

+1

I'm trying to use this in conjunction with Unique Field module, but without this module correctly falling back to the autocomplete widget upon node edit, the two do not work together.

elly’s picture

+1 I'm getting the same behavior (plain text box), though it seemed the autocomplete fallback field did work when first added, but now after moving the node forms around (into custom ctools panels content types), it has stopped working anywhere, even on the default node/add form.

elly’s picture

bueller?

SharkMachine’s picture

It seems that autocomplete_match isn't set and that's why it doesn't return anything after making the change in post #1.

I got it working by adding it to the widget settings, making the nodereference_url_widget_info -function look like this:

function nodereference_url_field_widget_info() {
  return array(
    'nodereference_url' => array(
      'label' => t('Reference from URL'),
      'description' => t('Node Reference calculated from URL'),
      'field types' => array('node_reference'),
      'settings' => array(
        'autocomplete_match' => 'contains',
        'fallback' => 'select',
        'node_link' => array(),
        'edit_fallback' => 0,
      ),
    ),
  );
}
droath’s picture

I made the changes that both post #1 and #5 suggested, and it looks like that solved the problem. I also added some code to the "nodereference_url_field_widget_settings_form" function so we can expose additional autocomplete matching options.

droath’s picture

Status: Active » Needs review
Matthew Davidson’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.24 KB

Minor tidying up. Made patch relative to module directory, removed some trailing whitespace. Works for me. Thanks @droath.

bforchhammer’s picture

#8 solves the problem for me as well.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Excellent, thanks everyone! Sometimes it's hard keeping up with the References folks. :)

Committed to the 7.x branch. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.