I have a "person" content type that uses two node reference fields: one to point to a "spouse" person, and the other to point to a "child" person; i.e. these are all "person" content types. I'm viewing a specific person content and I use the link configured by Node Reference URL Widget to "add a spouse." When the new content is created, the spouse node reference field is prepopulated with the specific person link, but so is the child node reference field!

It seems to me that only the spouse field should be updated when I use the spouse link, and only the child field should be updated when I use the child link. However, in both cases both fields are being updated.

Comments

tgshannon’s picture

This are my field setups.

field_mother

Label: Mother

Widget type: Reference from URL

Fallback behavior: *
Use autocomplete widget

If no content is referenced in the URL, determine how the form should be handled.
Use fallback behavior when editing content

create link on full view

link title: Add child

return path: the new node (no redirect)

field_spouse

Label: Spouse

Widget type: Reference from URL

Fallback behavior: *
Use autocomplete widget

If no content is referenced in the URL, determine how the form should be handled.
Use fallback behavior when editing content

create link on full view

link title: Add spouse

return path: the new node (no redirect)

quicksketch’s picture

Title: multiple node reference fields pointing to same content type are getting updated when one of the node reference fields is used? » Multiple node reference fields pointing to same content type are getting updated when one of the node reference fields is used
Priority: Normal » Minor

Hm, I'd agree that this is unusual behavior. This module wasn't really designed to work with more than one node reference field on the same content type. Note that you can work around this issue by using a module like Custom Links, and instead of making links like node/add/[type]/[nid], you can make links to node/add/[type]?spouse=[nid], and Node Reference URL Widget will pick up the relationship that way. Read the README.txt for more information on this approach.

So this definitely still qualifies as a bug, but one that you can work-around relatively easily. Perhaps the solution for Node Reference URL Widget is to make the automatically-created links follow this same pattern when more than one node reference field is on the new node type.

quicksketch’s picture

henrijs.seso’s picture

just to make life easier, lets change default pattern like ?field=[nid]. Im not big fan of idea thou, since field names are 1) usually ugly and 2) could tip off some setup architecture, naming convention or pattern and therefore be security hazard

quicksketch’s picture

just to make life easier, lets change default pattern like ?field=[nid]

That sounds like a good idea to me, but I think we should only take that approach if there is a reason to use that format (such as if there are multiple fields). I personally like the "short" format unless there are unusual circumstances.

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new4.28 KB
new4.4 KB

I've committed these patches to address this problem.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.