views:

199

answers:

2

Hi.

This is the same question of this link:

http://stackoverflow.com/questions/1515722/removing-nidn-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 content, the [nid:n] appears again.

Anybody can help me?

A: 

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()

googletorp
A: 

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!

Snazzy

related questions