First, thanks so much for this extremely handy module - great idea and I keep finding more uses for it!

It seems that the autocomplete widget (when used as fallback behavior) only accepts referenced fields with a maximum size of 128 characters. I started with the References module and see that 128 character max issue came up and has been addressed in 7.x-2.x-dev (see http://drupal.org/node/1183300), which I have installed and tested to confirm that it allows me to set up a node reference field using the autocomplete widget that accepts fields of 200+ characters. And if I set up a node reference field using the 'Reference from URL' widget, I can similarly reference fields of 200+ characters. However, when the autocomplete fallback comes into play (i.e. I don't create the content via the link on the referenced node) suddenly I get an error message that the referenced field cannot be longer than 128 characters. Since the limit isn't there unless I am using the Ref from URL as my primary widget, I assume this module is implementing it. Is there a way to remove this limit or at least increase it to match the 255 limit on fields generally?

Thanks very much.

Comments

etomilin’s picture

Category: task » bug

Stumbled on this problem too. I solved it the same way as it was done in reference module, i.e. by adding '#maxlength' => NULL, to autocomplete section of nodereference_url_field_widget_form:

elseif ($fallback == 'autocomplete') {
  $element += array(
    '#type' => 'textfield',
    '#default_value' => isset($items[$delta]['nid']) ? $items[$delta]['nid'] : NULL,
    '#autocomplete_path' => 'node_reference/autocomplete/' . $instance['entity_type'] . '/' . $instance['bundle'] . '/' . $field['field_name'],
    '#value_callback' => 'node_reference_autocomplete_value',
    '#element_validate' => array('node_reference_autocomplete_validate'),
    '#maxlength' => NULL,
  );
}
quicksketch’s picture

Thanks guys, good suggestion. Though I have to wonder what users will know filenames more than 128 characters offhand. ;)

128 characters is the default in Drupal if you don't specify otherwise. Rather than NULL, I think a limit of 255 would be acceptable since its the reasonable file name length limit for most file systems, see http://en.wikipedia.org/wiki/Comparison_of_file_systems. More characters than that and you're just risking users copy/pasting an entire book into the field.

etomilin’s picture

Not sure why are you talking about filenames, since the string in question is node title ;)
Node title field itself can be 255 characters long, and autocomplete widget enlarges this string by adding overhead of [nid: $nid]. So setting the limit to 255 will still cause this issue if the node title is long enough.