I have a content type with three nodereferences:
NodereferenceA
NodereferenceB
NodereferenceC
which are supposed to reference nodes of the three different content types A, B and C. Actually, NodereferenceC is an unlimited set, but I don't know if it is relevant.
If I enable Modal Nodereference for NodereferenceC and fill it before I fill NodereferenceA and NodereferenceB, I get that NodereferenceA and NodereferenceB are filled in with the same value as the node I create in a modal window for NodereferenceC. This leads to validation errors.
If, instead, NodereferenceA and NodereferenceB have already been filled when I open the modal windows for NodereferenceC, I don't experience the issue.
Comments
Comment #1
whytewolf commentedI am also have this issue.
Comment #2
mbutcher commentedI can replicate this too. Looking into a patch.
Comment #3
very_random_man commentedAlso, if you have multiple value modal_noderefs with an empty field and a modal_nodref underneath, the second field will populate the empty multi-value field instead of itself.
I think the problem is probably down to how it identifies which form element to update with the newly created reference.
Multiple modal-noderef fields all have the same class so it will populate all empty fields. The Create link needs relating to the field in someway. I would guess that the nodereference field id needs to be added in some fashion.
Would it be semantically correct to use the rel attribute of the link for this?
Comment #4
robert castelo commentedShouldn't it target the field ID?
That would also make it quicker.
Comment #5
very_random_man commentedYes. My suggestion was to keep the id of the the target nodereference element in the rel of the clicked link so that the button contains the means to directly identify the appropriate target.
Comment #6
gleroux02 commentedI am wondering if this may also just be an easy fix in modal_noderef.js. It looks like this problem can be solved by switching how the last form field is found from prevAll() to prev(). I will test and try to get a patch up.
Comment #7
gleroux02 commentedHere is that patch. It is replacing prevAll() with prev().
Comment #8
sutharsan commentedHere is another patch based on Robert's suggestion to use the id of the field wrapper.
Comment #9
jdschroeder commentedFor me, installing either of those patches results in an alert box error message of "All available items are full. Either delete one or try adding another item first." upon clicking on any "create new" link.
Comment #10
jdschroeder commentedFor what it's worth, my current workaround is replacing the aforementioned
prevAll('div')withprevAll('div:first'). That seems to be doing the trick, for now.Comment #11
sutharsan commented@jdschroeder: can you describe your situation so others can reproduce your situation where the other patches did not apply?
Comment #12
jdschroeder commentedSure.
I have several different node reference fields, each referencing a different content type, and all have the option to use modal_noderef enabled. As described in the original issue, if I use the modal window to create a new referenced node, any item above that was left blank is populated with the same node reference data as the targeted field.
I have separately tried each of the patches from comments 7 and 8. In both instances, when I click on the link below the field that should summon the modal dialog box, I instead receive a javascript alert box with the error message "All available items are full. Either delete one or try adding another item first."
The wildcards here may be that I am using the 1.6 release of Modal Frame API and not using jQuery Update. I will give it another try with modalframe 1.7 and updates to jQuery and jQuery UI.
Comment #13
paulmckibbenWell, here's my attempt at fixing it, and my rationale for this approach as opposed to the others offered here so far.
The approach:
1. This patch still uses prevAll().
2. Instead of passing the full result of prevAll() to firstEmpty(), this patch iterates one-by-one through the prevAll() results and STOPS once firstEmpty returns a valid field. This prevents the other fields from being filled.
Why not use prev() instead of prevAll()? Because I want to be safe--though I have not run into a scenario where prev() wouldn't work, I'm assuming that the original author had a good reason.
Why not use the rel attribute? Because that appears to be a non-standard use of the rel attribute, based on my reading of the XHTML standard. Take that for what it's worth. :)
Comment #14
mbutcher commentedAnyone tested this patch? Is it working solidly?
Comment #15
internetter commentedPatch in #13 works for me. Without it has filled other Noderefs, with it does not!
Greate work! Thanks.
Comment #16
momper commentedthe same for me:
Patch in #13 works for me. Without it has filled other Noderefs, with it does not!
Greate work! Thanks.
Comment #17
mbutcher commentedThe patch in #13 has been pushed into CVS.