Hi starbow,
(Creating new issue for the D5 branch - from comments #5–7 in #332459: Created node doesn't display in node-reference list after popup node creation)

This module is amazing! After struggling with many other "solutions" we are now one step away from add-n-reference nirvana! So here's the bug...

The popup is successfully creating the new node, but then popup doesn't correctly display success message and (most important) new node isn't added to the node-reference drop-down in the base form.

Here's what happens for me with 5.x-1.0-beta1:

Let's say my base node type is Employee, and the node-reference is to type Supervisor.

  • On the Employee node add form, I click the "Add Supervisor" link
  • Popup appears with node add form for Supervisor
  • I fill out form and click "Submit"
  • Pop-up disappears and I see the "loading" animation for a few seconds.
  • New pop-up appears with success message "Your Supervisor has been created", but this new popup is a blank Employee add form - which I was in the middle of filling out on the base page.
  • I close the modal, the drop-down list on the base form does not contain the newly added node as an option.

From http://drupal.org/node/332459#comment-1105491 my understanding of the expected behavior is a small modal notification window with the success message and an OK button - when dismissed this should return to the original form, with the new referenced node inserted as an option into the select list.

I looked at the code and was humbled - it was a bit beyond me. I will test any patches right away.

thanks,

- Andy

CommentFileSizeAuthor
#13 underscores.patch856 byteslaken

Comments

starbow’s picture

Assigned: Unassigned » starbow

This is a great bug report. I will do some testing and let you know what I find out.

laken’s picture

Thanks, looking forward to it.

mlncn’s picture

Confirming this; I almost missed this issue. I don't see anything special about our set-up (except it being 5.x). When submitting pop-up (referenced) node, full page reload results in losing data belonging to base (referencing) node. Rather than adding the drupal_set_message regarding a new node type being added via AJAX, popups / popups_reference appears to be doing this by triggering a page refresh. The popup box looks great, the new node is submitted, but the source node form sees its page refreshed, which wipes out custom formatting.

Thoughts, pointers on where to look at the differences between D5 and D6 (which works)?

Andy and I are in the same room right now on a code sprint for an all-new Trade Justice web site in Drupal, as well as needing the module for our own projects, so will be very responsive to anything we can do tasks assigned back to us!

benjamin, Agaric Design Collective

laken’s picture

Just a polite bump - it's been about a month. Have you been able to look at this?

As Ben said, we are jonesing for this for D5, and will help any way we can to get this fixed!

starbow’s picture

Ok, I believe I have isolated this problem, and should have a fix for you to try in beta2, which is coming soon.

will_in_wi’s picture

This also happens in version 6.x-1.0-beta2.

Update:
Never mind, I am having a different issue.

laken’s picture

That's great! We are eagerly awaiting beta 2.

In the meantime, do you think the development DRUPAL-5 branch (1.3.2.4) is okay to use for now?

starbow’s picture

Feel free to test. I wouldn't use it in production.

laken’s picture

Just updated popups_reference and popups to latest DRUPAL-5 branch. In testing, I can see no difference from the previous behavior as described in the bug report above. Fix not working for me - am I missing something? How can I give a more helpful test report?

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

@alaken: Ok, the fixes I implemented addressed the problem raised by Benjamin in #3, but it appears that is not the same issue as you are having. I have not been able to replicate your issue. I can, for example, add a story node ref to a page, click "create content >> page", click "Add Story", get the create story form in a popup, fill it out, click "Submit", see the "Story Created" message in a popup, and then select the new story in the select box.

So lets think this through. When the /node/add/story form is submitted, it's default behavior is to go the the /node/nid page. Popups sets the destination parameter to "/node/add/page", and it know that it is done when it returns to that page. This is how Popups can handle when a form fails validation. From your description of the bug, it sounds like after you submit the /node/add/supervisor, it is successfully returning you to /node/add/employee, but Popups is not recognizing that fact. Is the url of your original page aliased to something other than /node/add/employee?

Using Firefox, here is what I see, starting at /node/add/page and doing the processes I described above:

GET http://localhost/drupal-5/node/add/story?destination=node/add/page
POST http://localhost/drupal-5/node/add/story?destination=node/add/page
GET http://localhost/drupal-5/node/add/page

What is your initial url, and what do you see in Firefox doing those same basic steps with your employees and supervisors?

71

laken’s picture

Tao,

Thanks for the update - I'm just now got the time to get back into this.

First, I tried your simple test with Story and Page, and it worked! Okay! Yes!

As to find out why my actual content types aren't working, turns out it fails with base content type names containing underscores.

Taking a cue from your notes above, I isolated the problem. I was using "employee" and "supervisor" as easy examples, that's not my real use case or names. The real name for the base content type is tally_record and the name for the referenced content type is state_group. For some reason the URL drupal generates for the node/add is node/add/tally-record (you'll see this on the Create Content page node/add) - notice it's changed the underscore to a hyphen.

Here's the URL the popup_reference is generating:

http://localhost/node/add/state_group?destination=node/add/tally_record

The problem is coming from the mismatch between the "tally-record" in the base form URL and tally_record in the destination parameter. I used Firebug to edit the destination parameter to ?destination=node/add/tally-record and it worked!

Note also that if I use the URL http://localhost/node/add/tally_record the popup reference also works fine, that's just not the URL that Drupal's generating.

An obvious workaround for now would be to rename the content types so they have no hyphens. But something tells me this is now enough information to fix the problem. (I recall seeing a diff of the code at some point over the last 6 months which seemed to deal with conversion from hyphens to underscores, but I can't find it now.)

Let me know if I should move this to a new issue with title like "fails with base content type names containing underscores"...

laken’s picture

Don't have time to roll a patch at the moment, but adding this after line 95 of DRUPAL-5 branch of popups_reference.module seems to do the trick:

      $type = strtr($type, '_', '-');
      $src_type = strtr($src_type, '_', '-');

I'm sure there are better/cleaner ways to do this, and we might want to check the actual URL to see if it's using underscore or hyphen...

laken’s picture

StatusFileSize
new856 bytes

Patch now included .

starbow’s picture

Status: Postponed (maintainer needs more info) » Needs review

Great, thanks for tracking this down. I will try it out.

starbow’s picture

Status: Needs review » Fixed

In beta2

Status: Fixed » Closed (fixed)

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

nodecode’s picture

Version: 5.x-1.0-beta1 » 5.x-1.0-beta2
Assigned: starbow » Unassigned
Status: Closed (fixed) » Needs review

Looks like laken's fix did not work on my system. I am using Drupal 5.17 w/ beta2 version (which has laken's patch applied) and it is doing the exact same thing as described in the original post. I cannot use this module successfully with content types that contain underscores in the names OR those that have only a one word name (like Story and Page). Originally i thought it was an underscore issue so i was testing different configurations as per this thread and i DID get it to work ONCE using Page reference inside of a Story node. But i haven't been able to reproduce this success...can anyone else with a similar setup confirm that this is NOT working properly for them? This is really a lovely module when it works, but i'm pulling out my hair here...

after testing i've decided to create a new issue...