Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There appears to be an issue with IEF and the new AJAX implementation on 7.39 version of core.
When editing any nodes that have an entity reference field, and use the IEF widget, the edit form fails to update when the user clicks on either "add new" or "add existing" buttons. The following error is reported in the log:
Notice: Undefined index: #ajax in ajax_form_callback() (line 395
This has only happened since the update to 7.39 core, and may be linked to the AJAX security changes in this version.
Comment | File | Size | Author |
---|---|---|---|
#7 | ief-core-7.39-ajax-verification.patch | 939 bytes | adwuk |
Comments
Comment #2
adwuk CreditAttribution: adwuk commentedIt looks like it could be a problem with core 7.39. I have modified core/includes/ajax.inc at line 394 to the following to check if array index #ajax is set:
The IEF now renders for the creation of a new entity, but I still have a problem with the form submission not completing.
Comment #3
carsonblack CreditAttribution: carsonblack commentedI can confirm that this issue exists and appears to have been caused by the Drupal Core 7.39 update.
Note the release notes page for 7.39 (https://www.drupal.org/drupal-7.39-release-notes) state:
"The Ajax system now validates URLs before making an Ajax request. Existing code which uses the Drupal Ajax API in any of the standard ways should continue to work after this update. In the event you have unusual Ajax code which does not work with Drupal 7.39, you can have your code manually validate the URL in one of two ways. Either add the URL to the "urlIsAjaxTrusted" JavaScript setting (see ajax_pre_render_element() for an example) or call ajax_set_verification_header() in the Ajax callback function to mark the current URL as trusted. Only do this for URLs that you actually trust; Ajax requests in Drupal should never be made to untrusted URLs."
Comment #4
carsonblack CreditAttribution: carsonblack commented@adwuk: what theme are you using?
I noticed when I turned off our Omega based theme and used Bartik everything works just fine.
Comment #5
adwuk CreditAttribution: adwuk commentedI'm using the Danland theme, although pretty heavily modified in places. I have just checked using IEF as an admin, using the Seven theme, and it also fails with the same error when trying to add a new entity via an existing node.
Comment #6
adwuk CreditAttribution: adwuk commentedJust tried adding
ajax_set_verification_header();
at line 845 of inline_entity_form.module (first statement in function inline_entity_form_entity_form()). It appears to have done the trick. Was it really that simple?Comment #7
adwuk CreditAttribution: adwuk commentedhere is a patch that will hopefully work for others
Comment #8
carsonblack CreditAttribution: carsonblack commentedadwuk's patch might be a good idea nyway, but for my case we found that Omega was being a bit too heavy handed with it's interference with Drupal.settings so there is an issue for that now: https://www.drupal.org/u/segovia94
And this was really a problem when you had the Dialog API module turned on, which we did. Dialog module is also fairly greedy about where it injects itself, so there might need to be something done there as well.
Comment #9
ansonwhan CreditAttribution: ansonwhan at Eastern Standard commentedWorth noting, if you have Secure Pages enabled- be sure the base url set there doesn't conflict with the url making the request, especially if you have multiple domains parked/aliasing the same instance.
Comment #10
annared CreditAttribution: annared commentedDoes anyone know if this problem persist in Drupal 7.41?
Thanks
Comment #11
mibfire CreditAttribution: mibfire commented@annared
This problem exists in 7.54 too.
Comment #12
apadernoI corrected the issue tags. I apologize for bumping this issue.