Download & Extend

nodereference does not show saved field during node edit

Project:Content Construction Kit (CCK)
Version:6.x-1.x-dev
Component:nodereference.module
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I created a content type with a nodereference field. The referenced node saves fine, as it displays the referenced node when viewing the node. However, when I go to edit the node, the entry in nodereference is forgotten - this happens for both ajax and select-list. This does not happen with the userreference type.

Ian

Comments

#1

It does propagate the field correctly when you edit the node while the field is set to allow for multiple entries.

#2

Component:Code» nodereference.module

#3

Status:active» needs review
AttachmentSize
nodereference-default-value.patch 1.64 KB

#4

The values were being forgotten for me for multiple selects also.

nodereference-default-value.patch applied and fixed both single and multiple selects - I did not test with an ajax field.

#5

Works for me on select widgets (single and multiple)
I updated the patch to make this work with ajax-autocomplete as well.
I tested it on both single and multiple values

AttachmentSize
nodereference.module.patch 2.32 KB

#6

I re-read my post and realized it was ambiguous. Let me rephrase:

I tested the first patch, and it did fix the issue on select widgets (single and multiple), but not on autocomplete widgets.

I upgraded the patch to fix the issue on autocomplete widgets as well.

#7

Priority:normal» critical

I forgot two lines - it seems that it works without this additional correction, even though I don't understand how... I guess it is caught and corrected by db_query

(it is in both insert and update part, in the case of a non multiple autocomplete widget)

- db_query("INSERT INTO {node_field_nodereference_data} (nid, vid, field_name, delta, field_nid) VALUES (%d, %d, '%s', %d, %d)", $node->nid, $node->vid, $field['field_name'], $delta, $node_field['relation']);
+ db_query("INSERT INTO {node_field_nodereference_data} (nid, vid, field_name, delta, field_nid) VALUES (%d, %d, '%s', %d, %d)", $node->nid, $node->vid, $field['field_name'], $delta, $node_field['relation'][0]);

(added '[0]' at the very end)

(setting the priority as critical, BTW, because it is indeed...)

AttachmentSize
nodereference.module_2.patch 3.33 KB

#8

Status:needs review» fixed

Should be fixed in current CVS after the nodereference.module refactoring.

#9

Status:fixed» closed (fixed)
nobody click here