Hello folks,

I have an issue I cannot figure out: I have multiple widgets on the same node add page (that use the admin theme).
On my dev. environment, it works like a charm.

But since I commit to another server, I just can't do anything that implies Ajax. After a long while (at least 7-8 seconds), all views on the page are reloaded with the front theme (not the admin one) and I just can't do anything beyond this point.

After digging a little further, I realized that the theme callback (ajax_base_page_theme) does not receive $_POST['ajax_page_state']['theme'], even though it was actually sent by Ajax.

Forcing the theme callback to return my admin theme is also a problem: useless JS files that should not be loaded actually load and break the widget. Therefore, after adding 2 elements to the list, adding a third one provokes a JS error (Uncaught TypeError: Object [object Object] has no method 'once' in Drupal.behaviors.contextualLinks.attach)

I applied the patch in https://drupal.org/node/1309632 to have checkboxes, just it case it has something to see.

At this point, I don't really know what to do. Any idea is welcome !

Thank you very much !

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lavoiesl’s picture

Yes, I am having the same issue. The View seems to not know it is in admin.

lavoiesl’s picture

Here is a quick patch to use the admin_theme for ajax views.

jonastg’s picture

I'm working in a site with admin & front themes. When the widget loaded the view, the layout is broken because the ajax request loaded js/css from the front theme. Surfing the web I found this post http://www.duckzland.com/content/drupal-7-force-ajax-use-admin-theme and the first option works for me.

I added this chunk of code in .module file:

function entityreference_view_widget_admin_paths() {
  $paths = array(
    'entityreference_view_widget/*' => TRUE,
  );
  return $paths;
}
jsacksick’s picture

Thanks for spotting this, I committed the approach suggested by jonastg.

  • Commit a8d255e on 7.x-2.x authored by jonastg, committed by jsacksick:
    Issue #2137237 by jonastg, cslavoie: Implements hook_admin_paths() for...
danreb’s picture

I know this has been closed with the committed patches but now I am having problem using entity reference view widget in an entityform because it is now returning the response with js and css of the admin theme (seven in my case) and it's breaks the front end theme because entityform was not using admin path and the entity view reference widget now thinks that it always invoked inside an admin path.

Looking and reading in the link provided in #3 it seem's that solution 2 is the more correct way for this problem and it is also the suggestion here -> https://api.drupal.org/api/drupal/includes!ajax.inc/function/ajax_base_p...

anyone having same issue with me now?

SantVim’s picture

Same happens to me. I use adaptive theme for front, the widget only loads the admin theme.In my case the view is for authenticated users to select the nodes not just the admins, so its kind of important to sustain the front end look. Great module btw, totally loving it :)

jsacksick’s picture

Priority: Critical » Normal
Status: Fixed » Needs work

So mark this as needs work, feel free to post a patch, in the meantime you could still use the hook_admin_paths_alter(), See https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

jsacksick’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs work » Fixed

You should checkout the latest dev version, it should be fixed (the 2.x branch).

SantVim’s picture

Hey been testing the latest dev, works fine with the front end theme .... but the exposed filters in the view are not working...throws an AJAX HTTP error occurred (they were working good before in alpha3).... Should i open a new issue???

EDIT: If there is one exposed filter the ajax error occurs once and after dismissing it the ajax works. If there are multiple exposed filters the error persists and exposed filter vakues are not submitted.

jsacksick’s picture

I'm using the beta1 on two different sites and the exposed filters are working.

SantVim’s picture

Yeah...seems the issue was not due to exposed filters but because of exposed form autosubmit.
Unchecked the autosubmit now it works great.

Am using a user view with the state and city exposed.
I've selected a few users in the modal and closed it. Now, without saving the node form if i open the modal again the exposed filters stop working.

jsacksick’s picture

@Dhamub you're right, it wasn't working anymore, apparently because the js workaround we have wasn't triggered anymore on click because of the ajax behavior added to the add more button, this workaround is here due IMO to a views bug, See #1809958: Views with exposed filter (ajax enabled) inside modal window (ctools), in the meantime I updated our js workaround to react on "mousedown" instead of "click", See f92ba1e

Status: Fixed » Closed (fixed)

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

Yuri’s picture

Status: Closed (fixed) » Active

Installed the latest dev..and still the Ajax error 200 appears when using an exposed filter.
I'm using the Omega 3.1 theme, and it seems it can't find the responsive style sheet of the theme.

jsacksick’s picture

Status: Active » Closed (cannot reproduce)

Hi, I just tested the latest 2.x dev version with omega 3.1 and omega 4.2 with the node_admin_theme variable set to 0 (Meaning node add form on front). and everything worked as expected.

nithinkolekar’s picture

Status: Closed (cannot reproduce) » Active
FileSize
252.83 KB

This problem is still exist.
Tested with bootstrap subtheme as main theme and seven as admin theme where admin theme is set for creating and editing node pages.
ervw-ajax-admin-theme

NIKS_Artreaktor’s picture

@nithinkolekar

Try increase max_input_vars = 2000 (by default 1000)
It helped me with on admin theme Seven (non bootstrap theme) and Bootstrap -as base theme.

(https://www.drupal.org/node/2156371#comment-10634956)

OR

Try module
https://www.drupal.org/project/themekey

Added rule
If drupal:path = system/ajax (for example)
to use Admin theme.

I could help.

rooby’s picture

There still seems to be something up with this.

I have a template preprocess function in my default theme (the theme used for the node field in question) after adding values to my entity reference field it doesn't run the code, however when you next load the form it does.

rooby’s picture

I think this is related: #2534874: Does not update the $form_state variable when a selection is made.

When you click the add another button it does some ajax and loads the view modal, which is potentially in a different theme. Then when you submit the modal, ajax replaces elements in the original form (which again, may not be in the same theme).

The problem seems to lie in having the ajax submission of the views form replacing elements in a different form.