Closed (duplicate)
Project:
References
Version:
7.x-2.x-dev
Component:
Code: node_reference
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2011 at 11:48 UTC
Updated:
14 Dec 2011 at 03:15 UTC
Jump to comment: Most recent file
Comments
Comment #1
aidanlis commentedSubscribe. In my opinion this is a release blocker.
Comment #2
damienmckennaI believe this is because the default maxlength on a textfield in D7 is 128 characters:
Comment #3
damienmckennaHere's a quick patch to add '#maxlength' => 255 to the fields. I didn't touch user_reference as the {users}->name field's length is 60.
Comment #4
MichaelP commentedPatch at #3 good for me. Thanks to @DamienMcKenna
Comment #5
scor commentedtested the patch and it fixes the validation issue.
Comment #6
yched commentedCommitted. Thanks !
Comment #8
golubovicm commentedHello,
I'm running Drupal 7.2 and I got same problem - title limit for referenced nodes is 128 chars.
I found this patch and tried to implement it, but I found out that row
'#maxlength' => 255,
already exists in node_reference.module file?!? It's not 456th row, like patch says, but 540 (probably newer version of Drupal, but it won't work - limit is still 128 chars.
Is ti possible that patch is implemented badly, so it won't work. Here is how my function looks like:
function node_reference_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
switch ($instance['widget']['type']) {
case 'node_reference_autocomplete':
$element += array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['nid']) ? $items[$delta]['nid'] : NULL,
'#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $instance['entity_type'] . '/' . $field['field_name'],
'#size' => $instance['widget']['settings']['size'],
'#maxlength' => 255,
'#element_validate' => array('node_reference_autocomplete_validate'),
'#value_callback' => 'node_reference_autocomplete_value',
);
break;
}
return array('nid' => $element);
}
Comment #9
scor commented@golubovicm this patch has already been committed and you should not have to try to apply it as long as you are using one of the beta version of this module.
Comment #10
golubovicm commentedThank you for reply scor.
I didn't applied it - I just checked what it changes and found that it just adds one row:
'#maxlength' => 255,
which already exists in my version of module. But titles are still limited to 128 chars, so I don't know how to solve this? How to change title limit? Is problem dev version of reference module?
Comment #11
golubovicm commentedTo be more precise, I'm using autocomplete deluxe node reference field.
Comment #12
scor commentedtested the latest beta and -dev, and the 255 limit works, I have
maxlength="255"in the appropriate input HTML element. It looks like you might have another module which might alter the form. Please file a separate support issue to discuss this further.Comment #13
golubovicm commentedThank you scor. I'll look for that other module.
Comment #14
golubovicm commentedI have found that only "acdx_references" module (auto complete deluxe) is overriding that function and inserted maxlength there too, but unfortulatelly didn't help. So I give up on this... :(
Comment #15
scor commentedactually, 255 is not enough for nodes which reach the limit of the node title length because we also need to account for the ending [nid:xxx] which can take up at least 7 chars but be much more on large sites. so the maxlength is unpredictable. This patch unsets the maxlength altogether.
Comment #17
grndlvl commentedThis patch solves the problem of the field not accepting 255 characters(Necessary since node supports 255 characters).
We solve this by using a function that accounts for the nid information as well as the title that may be referenced throughout the module and other modules(node references dialog).
Patch was applied to 7.x-2.x-dev
Comment #18
grndlvl commentedApologies but please Ignore the patch from #17. Accidentally made from Drupal root.
The following patch contains the only the proposed fix, again for 7.x-2.x.
Thanks,
Jonathan
Comment #19
scor commentedclosing this. This is being solved at #1183300: remove maxlength from node_reference_autocomplete where yched provided a valid rationale: "The value that we store from the widget is a nid anyway, so I'm not sure what's the point of settings a #maxlength on the textfield form input anyway ?"