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.

CommentFileSizeAuthor
#7 ief-core-7.39-ajax-verification.patch939 bytesadwuk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adwuk created an issue. See original summary.

adwuk’s picture

It 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:

  if (!empty($form_state['triggering_element'])) {
    if (!empty($form_state['triggering_element']['#ajax'])) {
          $callback = $form_state['triggering_element']['#ajax']['callback'];
    }
  }

The IEF now renders for the creation of a new entity, but I still have a problem with the form submission not completing.

carsonblack’s picture

I 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."

carsonblack’s picture

@adwuk: what theme are you using?

I noticed when I turned off our Omega based theme and used Bartik everything works just fine.

adwuk’s picture

I'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.

adwuk’s picture

Just 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?

adwuk’s picture

here is a patch that will hopefully work for others

carsonblack’s picture

adwuk'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.

ansonwhan’s picture

Worth 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.

annared’s picture

Does anyone know if this problem persist in Drupal 7.41?

Thanks

mibfire’s picture

@annared

This problem exists in 7.54 too.

apaderno’s picture

Issue tags: -7.39 AJAX +7.39, +Ajax

I corrected the issue tags. I apologize for bumping this issue.