Thanks a lot for usefull module.

But, when I create base-related content, how to make Node Reference field become filled with relevant (just created) reference on popup close.




starbow’s picture

The module does not select the newly created node for you, it just adds it as a possibility. You still need to select the new node after creating it.

starbow’s picture

Status:Active» Fixed
kswan’s picture

Version:6.x-1.0-alpha» 6.x-1.x-dev
Category:support» feature
Status:Fixed» Active

How difficult would it be to add this functionality? I am starting to look into it and I hope I can figure it out, but I am pretty weak at JS.

Would it work to add an AHAH callback to the nodereference widget on the base form, then make the appropriate callback after submitting the popup form? Of course I am glossing over a lot of details that I don't understand, but I am on the right track?

starbow’s picture

I doubt AHAH will help you. The trick is you need to determine the nid of the newly added node to be able to select it, and I am not sure where that into is available.

meba’s picture

Forgive me for any misunderstanding, I haven't seen the module live yet, my friend just asked me to comment on this issue as he is trying to solve it too :-)

As I understand, this module creates a popup presenting node add form during editing any other node, useful for Node reference.
What I would do is add a GET parameter to the popup page (Such as node/add/page?popup=1).
Based on this, I would alter the node form to include this parameter in a hidden field, using hook_form_alter. (Or include it as a field in the node form)
Then, I would use hook_nodeapi with $op = insert and based on the popup value, I wouldn't permit Drupal to load & view the node, but just print a javascript which fills the original node form and exits.

Does it make sense?

scottrigby’s picture

Hi starbow,
Along similar lines, but not quite as involved--- Is it possible to just see the created node in the node-reference list after popup node creation?
Here's what happens for me:
* I click 'Add new' link
* Node is added (yay!)
* Modal redirects to create content, which I want to close
* After closing the popup, my newly created node does not appear in the node-reference field. I have a multi-select.
Is this by design? I assume it isn't because it kid of defeats the purpose of add & reference. Kind of only 'add' but can't reference :(
I tried with 6.x.1.x-dev and 6.x0-1.0-beta1, with similar results (the only difference is, in the dev snapshot the create content window is not called, but another node of the same type we're originally in... the parent node containing the node-reference). So i'm guessing it's not the version - maybe something with my configurations?
I'm hoping to find out what I must be doing wrong though, because this module would really solve a lot of my dilemmas ;)

Ok - moved to separate bug report: #332459: Created node doesn't display in node-reference list after popup node creation

starbow’s picture

@scottrigby: what you are describing sounds like a bug. It should be behaving like you expect. You should open a separate issue.

starbow’s picture

@meba: if that approach works, please post the code. Don't forget you still need to reload the new form element into the original page.

starbow’s picture

Status:Active» Fixed

The feature will be included in the next release, which will be 1.0-RC1. It will require the next release of the popup API, which will be 1.2-RC1

Status:Fixed» Closed (fixed)

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

cYu’s picture

Status:Closed (fixed)» Needs review

Can the following line be changed in order to stay consistent with how autocomplete nodereferences display? I believe I'll need this for #393002: Edit Node reference so that I can get the nid for both newly created and existing nodereferences, although I was hoping there would be a better way to do so besides pulling it from that string.

("PopupRefTitle", rawurlencode($node->title), $five, '/');


("PopupRefTitle", rawurlencode($node->title. ' [nid:'. $node->nid .']'), $five, '/');
starbow’s picture

If this change does not break anything, I am happy to put it in.

starbow’s picture

Assigned:Unassigned» starbow
sirkitree’s picture

I was using this in a similar way on my site. I didn't come up with a cookie based solution - more traversing the DOM to construct this and then placing it as the value purely in javascript, but if a user is using the autocomplete widget it's very important.

sirkitree’s picture

Tested the above and it works just fine for autocomplete, but I'm not sure that it's going to work for other widgets...

cYu’s picture

The other widgets don't use the title, they only use the nid, so this should not affect them.

sirkitree’s picture

Well that's my point: the other widgets just use nid. So if we're always returning title[nid:#] isn't that going to screw up the other widgets? I'm suggesting that we may have to detect which widget is being used in order to determine what to throw back at it.

cYu’s picture

The other widgets should be ok, they use a different variable that stores only the nid which is pulled from a separate cookie.

        var nid = popups_reference_get_cookie_value('PopupRefNid');
        var title = decodeURIComponent(popups_reference_get_cookie_value('PopupRefTitle'));
starbow’s picture

cYu is correct. The nid and the title are stored separately.

russbollesjr’s picture


greg.harvey’s picture

new511 bytes

Patch for #11 attached.

orniter’s picture

Version:6.x-1.x-dev» 6.x-2.0-alpha1
new16.2 KB

Anyone know if this behavior is corrected? I'm having the same issue as original post:
Adding a node is fine, the popup confirms the reference was added, but the reference field isn't auto-filled with the new content.

Attached screenshot details this problem.

Any information would be greatly appreciated!

momper’s picture


snufkin’s picture

Status:Needs review» Needs work

It looks like it only skips the first popup, for every other it works fine for me with the patch.