When editing entity an entity with relation select field(s):

  1. Press Search button in Relation Select field (page fonts change to smaller size -- as reported in comments #9 and #11 of #1307674: Notice: Undefined index: view_path in views_ajax(), line 26 of /sites/all/modules/views/includes/ajax.inc).
  2. Click views mini pager Next link (>>).
  3. JSON fills screen:
    [{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"mytheme","theme_token":"lOuEaYKFtKAm46sCn63sCT3Uwyj93HKaaQCpXPwpjvY","css":[]},"overlay":{"paths":{"admin":"node\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\nrelation-select\/add\/*\/*\ndevel\/*\nnode\/*\/devel\nnode\/*\/devel\/*\ncomment\/*\/devel\ncomment\/*\/devel\/*\nuser\/*\/devel\nuser\/*\/devel\/*\ntaxonomy\/term\/*\/devel\ntaxonomy\/term\/*\/devel\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"ajaxCallback":"overlay-ajax"}},"merge":true}]
    Browser location becomes: http://localhost/relation-select/ajax?vocab=All&term=&page=1&element_id=edit-field-test-relation-und-0&_triggering_element_name=op&_triggering_element_value=Search&ajax_iframe_upload=1#overlay-context=node/382
  4. Press browser Back button. Returns to entity edit page.
  5. Press Save.
  6. Error messages are set:
    1. Notice: Undefined index: _subform_element_name in relation_select_ajax() (line 883 of relation_select.module).
    2. Notice: Undefined index: ajax_page_state in relation_select_ajax() (line 897 of relation_select.module).
    3. Warning: Invalid argument supplied for foreach() in relation_select_ajax() (line 900 of relation_select.module).

Comments

steveoliver’s picture

Issue summary:View changes

Put URL in code to reveal entire address.

davexoxide’s picture

I can confirm this error. Weird thing is that I use this field on 1 content type and get the errors. I use this existing field within a different content type and no errors. I wonder if there's conflicting JS. Still digging into this.

davexoxide’s picture

Issue summary:View changes

Formatting.

steveoliver’s picture

@davexoxide: I notice the same thing--ajax pager works in some situations.

I think it's the Image field giving us grief...

Some testing:

Works:

  • Taxonomy term
  • Few fields
  • No field groups

Doesn't Work:

  • Node
  • Few fields
  • Several field groups: vertical tabs, divs, etc...
  • Autocomplete deluxe (Node/Term reference fields)

I tried this on the Not Working content type:

  • Remove autocomplete (change field type to regular select list) -- no help
  • Change Vertical Tab/Fieldset groups to 'Div'. -- no help

I tried this on the Working taxonomy term:

  • Add fieldgroup (Fieldset) -- still works
  • Add Image field (multiple or single) -- breaks (error in modal, not filling whole page):
    An AJAX HTTP error occurred.
    HTTP Result Code: 200
    Debugging information follows.
    Path: /views/ajax?destination=admin/structure/taxonomy/product_type
    StatusText: OK
    ResponseText: [{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"mytheme","theme_token":"ZIfUrAXjn9dt_3owGfy32wYI6oniJJgcGm2bBiDoI44"},"overlay":{"paths":{"admin":"node\/*\/clone\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*\nrelation-select\/add\/*\/*\ndevel\/*\nnode\/*\/devel\nnode\/*\/devel\/*\ncomment\/*\/devel\ncomment\/*\/devel\/*\nuser\/*\/devel\nuser\/*\/devel\/*\ntaxonomy\/term\/*\/devel\ntaxonomy\/term\/*\/devel\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"},"views":{"ajax_path":"\/views\/ajax","ajaxViews":{"views_dom_id:10fbf68ff10343d0f1a8656c3f2d8bab":{"view_name":"relation_select_node","view_display_id":"default","view_args":"","view_path":"relation-select\/ajax","view_base_path":null,"view_dom_id":"10fbf68ff10343d0f1a8656c3f2d8bab","pager_element":"0"}}}},"merge":true},{"command":"viewsScrollTop","selector":".view-dom-id-10fbf68ff10343d0f1a8656c3f2d8bab"},{"command":"insert","method":"replaceWith","selector":".view-dom-id-10fbf68ff10343d0f1a8656c3f2d8bab","data":"\u003Cdiv class=\u0022view view-relation-select-node view-id-relation_select_node view-display-id-default view-dom-id-10fbf68ff10343d0f1a8656c3f2d8bab contextual-links-region\u0022\u003E\n      \u003Cdiv class=\u0022contextual-links-wrapper\u0022\u003E\u003Cul class=\u0022contextual-links\u0022\u003E\u003Cli class=\u0022views-ui-edit first last\u0022\u003E\u003Ca href=\u0022\/admin\/structure\/views\/view\/relation_select_node\/edit\/default?destination=relation-select\/ajax%3Fdestination%3Dadmin\/structure\/taxonomy\/product_type%26type%3DAll%26page%3D1%26element_id%3Dedit-field-test-relation-taxonomy-und-0%26_triggering_element_name%3Dop%26_triggering_element_value%3DSearch%26ajax_iframe_upload%3D1\u0022\u003EEdit view\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003C\/div\u003E  \n  \n      \u003Cdiv class=\u0022attachment attachment-before\u0022\u003E\n      \u003Cimg class=\u0022relation-select-close\u0022 typeof=\u0022foaf:Image\u0022 src=\u0022http:\/\/localhost\/profiles\/mine\/modules\/contrib\/relation_select\/img\/close.png\u0022 width=\u002224\u0022 height=\u002224\u0022 alt=\u0022Close\u0022 \/\u003E    \u003C\/div\u003E\n  \n      \u003Cdiv class=\u0022view-content\u0022\u003E\n      \u003Cdiv class=\u0022views-view-relation-select\u0022 \u003E\n  \t\u003Ctable \u003E\n\t  \u003Ctbody\u003E\n\t    \t ... (table code) ...  \u003C\/td\u003E\n\t        \t      \u003C\/tr\u003E\n\t    \t  \u003C\/tbody\u003E\n\t\u003C\/table\u003E\n\u003C\/div\u003E\n    \u003C\/div\u003E\n  \n      \u003Cdiv class=\u0022item-list\u0022\u003E\u003Cul class=\u0022pager\u0022\u003E\u003Cli class=\u0022pager-previous first\u0022\u003E\u003Ca href=\u0022\/relation-select\/ajax?type=All\u0026amp;title=\u0026amp;element_id=edit-field-test-relation-taxonomy-und-0\u0026amp;_triggering_element_name=op\u0026amp;_triggering_element_value=Search\u0026amp;ajax_iframe_upload=1\u0026amp;destination=admin\/structure\/taxonomy\/product_type\u0022\u003E\u2039\u2039\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli class=\u0022pager-current\u0022\u003E2 of 9\u003C\/li\u003E\n\u003Cli class=\u0022pager-next last\u0022\u003E\u003Ca href=\u0022\/relation-select\/ajax?type=All\u0026amp;title=\u0026amp;page=2\u0026amp;element_id=edit-field-test-relation-taxonomy-und-0\u0026amp;_triggering_element_name=op\u0026amp;_triggering_element_value=Search\u0026amp;ajax_iframe_upload=1\u0026amp;destination=admin\/structure\/taxonomy\/product_type\u0022\u003E\u203a\u203a\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\u003C\/div\u003E  \n  \n  \n  \n  \n\u003C\/div\u003E","settings":null}]
  • Set image field from "Unlimited" to "Limit 1": same thing... error in modal
  • Removed image field: works again...
  • Added Boolean (single checkbox) field: still works...
  • Added decimal field, integer field (tested allowing multiple field instances), : still works...
  • Added Location field: still works...
  • Added Node Reference field: still works...

I conclude that the Image field breaks RS Views mini pager... :)

steveoliver’s picture

I also noticed that relation_select_ajax() is being called when "Search" is pressed ...but it is also called when the pager is clicked ... only if Image field is present on page. If no image field is on page where RS pager is clicked, the RS pager does not call relation_select_ajax a second time.

Something about Image field may be influencing/changing the callback for the Views pager?

davexoxide’s picture

I can confirm that once I removed the image field from this content type the error went away.

steveoliver’s picture

Status:Active» Needs work

hmmm...

steveoliver’s picture

Having done a little troubleshooting, I noticed the image field and other upload field such as a file field, for example (tested), adds a ajax_iframe_upload parameter to the Views mini pager link.

See how this parameter is used in ajax_deliver.

Jorrit’s picture

Status:Needs work» Needs review
StatusFileSize
new743 bytes

Could you try the attached patch? The AJAX handling in the Relation Select is not fully compatible with the Drupal mechanism that determines which CSS/JS files still have to be loaded. This fixed it for me.

The change in layout is because without the patch, Drupal thinks that the AJAX handler is displayed using the front theme, not the admin theme.

davexoxide’s picture

I've tested this patch and it didn't get rid of the error.

steveoliver’s picture

Status:Needs review» Needs work

Jorrit,

The first part of your patch has been committed in #1805098: ajax callback breaks theming.

Now we gotta figure out what's up with the Views mini ajax pager, and why it seems ajax_iframe_upload seems to be related to the problem.

Marking needs work.

Jorrit’s picture

I don't understand why you only committed one part, because the exit() in the current implementation of relation_select_ajax() prevents any of the theme callback / delivery callback settings from having any effect. Did you have trouble with the return array('#type' => 'ajax', '#commands' => $commands); line?

steveoliver’s picture

I committed the first part in that other issue because it resolved that issue, and the return array() in relation_select_ajax() did not fix the views pager issue.

Jorrit’s picture

But did it break anything?

steveoliver’s picture

The second part of your patch? No, it didn't break anything. But it didn't seem to fix the issue in this thread. What should be fixed with the last part of your patch?

Jorrit’s picture

Well, it is not that important, but returning a renderable array is the "Drupal" way and it allows Drupal to run (for instance) the exit hook after your page has completed. I will also try to see if I can find the source of the views pager not working.

steveoliver’s picture

Thanks. Just trying to keep issues on topic.

Jorrit’s picture

Status:Needs work» Needs review
StatusFileSize
new1.2 KB

Please try the attached patch. The whole iframe upload thing is invented to allow file uploads using ajax. However, views_ajax() doesn't work with this because it only works with button elements. The attached patch removes $_POST['ajax_iframe_upload'] for (hopefully) the right requests. The initial views request, the one that opens the popup, needs to keep using the ajax_iframe_upload method when Drupal expects this.

steveoliver’s picture

Status:Needs review» Closed (fixed)

Like I said, you are the man!

#16 fixes issue for me. Committed in 314c5c6.

Thanks.

steveoliver’s picture

Issue summary:View changes

Updating line numbers to reflect current code.