Node reference not being created on node add
laken - May 10, 2007 - 12:48
| Project: | Addnode |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Jump to:
Description
When I use addnode, both the main node and the node I'm creating with addnode are created, but no nodereference is created. I have a content type "Poster", and I'm using addnode to create the "Artist" referenced node. So both my poster and artist node get created, but the actual value of the node reference "Artist" field is not being set. I need to go back in to edit the Poster node and manually set the Artist field to the new artist. This seems to detract from the convenience of the module, and I don't think it's supposed to work this way.

#1
Hello, I'm having trouble duplicating the bug, maybe more info would be useful:
1) Is the page being viewed as part of a page route?
2) What is the url of the returned page? (I'm currently getting the nid from the url returned by the subform_element_call function).
3) What is 'required' and 'multiple' field settings set to?
4) Does it work with other node types?
5) What modules have you got installed that alter the form (eg location, image upload, etc...?)
6) Is there an addnode widget inside the subform too?
Thanks for reporting the bug,
It might be worth me putting some more debug info into the module to get a better idea what's going on, I'll release v1.3 in a few days and I'll remember to put more watchdog error reports in, hopefully then we'll be able to figure it out.
Thanks!
Mike.
PS If anyone else has had this problem with v1.2 (or 1.1) please post details, thanks!
#2
Hi, I'm having the same problem. When creating a new node I create a new node reference. When I submit the page, both are created, but the new node reference is not placed/selected. I tried testing with a clean base install of Drupal 5.1 with addnode 1.2, subform_element 1.2, and CCK 1.5. Also, something that should be added is that Addnode is dependent on Node Reference being enabled. I tried with only the Node Reference module enabled and with all of the CCK modules enabled. Hope this helps!
#3
I was having the exact same problem. Both nodes get created but the reference between them is not created. I poked around on the code and came up with a one line fix for the problem... I think. I'm new to the Drupal community so I'm not sure if I should post code here or not but here goes.
Add the following line to the addnode_fix_subform function just above the return statement.
$form_element['#form']['#fieldname']=$current_fieldname;This fixed it for me anyways
For some reason '#fieldname' is not getting set in the subform so when you get to saving the node reference in the addnode_addnids_submit function the $fieldname ends up being empty.
I hope me explanation make sense and my fix helps you figure out exactly whats going on.
Thanks for the great module!
#4
This fix works for me.
Thanks a lot!
#5
Thanks for the code snippet, works perfectly now!