How remove node ID [nid:n] in NodeReference fields
This is the same question of this link:
Removing [nid:n] in nodereference autocomplete
According with the first answer (Grayside) I've created my own module and activated. Then I create a new content, I look sth up in the nodereference field and finally select it -> it works (Doesn't appear the [nid:n]).
But, when I view/preview or save or edit the c开发者_运维技巧ontent, the [nid:n] appears again.
Anybody can help me?
When viewing the node, it is the theming function for the field that determines what is displayed, so you need to overwrite it, if you want to change the output.
The value when you edit the node, is determined by the #default_value
property, so you need to change in your hook_form_alter()
Thanks for the answer.
I've found the solution. (At least in my case)
I change the code of this file:
drupal\modules\cck\cck\modules\nodereference.module
function nodereference_autocomplete_value($element, $edit = FALSE)
{
...
// $value .= ' [nid:'. $nid .']'; --> Comment this line
return array($field_key => $value);
}
It works very well! Doesn't appear in any case: Not in selected from the list, nor when save, edit, etc.
Regards!
精彩评论