I am trying to get a node form to appear in the modal. No luck so far. Here's what I have-- the content type is "note". Any tips?

function mymodule_menu() {
  $items['node/add/note'] = array(
    'modal' => TRUE, // This line is where the magic happens.
    'page callback' => 'drupal_get_form',
    'page arguments' => array('note_node_form'),
    'access arguments' => array('administer user'),
    'modal' => TRUE,
  );
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

capellic’s picture

Status: Active » Closed (fixed)

Ah, of course, hook_menu_alter:

function mymodule_alter_menu_alter(&$items) {
  $items['node/add/note']['modal'] = TRUE;
}
capellic’s picture

I spoke too soon. Getting the following error:

An AJAX HTTP error occurred.
HTP Result Code: 200
Debugging information follows.
Path: /node/add/note/ajax
StatusText: OK
ReponseText: Access Denied
....

This is the same error that is occurring in this case: #1420526: getting An AJAX HTTP error occurred. HTTP Result Code: 200

Except I think what I'm trying to do is a lot simpler. I'm not passing in a destination on the link. It looks like this: node/add/note/nojs

capellic’s picture

Status: Closed (fixed) » Needs work

Changing status.

jlyon’s picture

Status: Needs work » Needs review

I updated the patched version of this module (see #1420534: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu() #4) so that it works with node/add pages. I needed to make a couple changes because the callback for those pages is node_add() not drupal_get_form() so ctools_automodal was serving it as a static page, not a form.

These changes are my fork of the module: https://github.com/jlyon/ctools_automodal.

SocialNicheGuru’s picture

i tried the new git hub version
Issues happen when there is a form within a form

so I used ctools_automodal_admin to have node/add/mycontent type popup
that works fine

I have a media 2 field.
I click on media and there is a popup that is blank.
and there is no way to get out of it

I then have entityconnect which has its own popup
a big ajax error came up
I was at least able to hit return to close the dialogue box

Edit:
I wonder if my issues stem from the basic architecture of modal in ctools
see: https://drupal.org/node/1470762

jlyon’s picture

Hmm, it sounds like like multiple jquery ui dialogs are conflicting with each other. I'm not sure I can offer a helpful solution.

I thought I had this working with a media 2 select field, but I may be wrong.

jlyon’s picture

Hmm, it sounds like like multiple jquery ui dialogs are conflicting with each other. I'm not sure I can offer a helpful solution.

I thought I had this working with a media 2 select field, but I may be wrong.

SocialNicheGuru’s picture

the media 7.2.x.dev issue might be it's own bug so let's remove that from the discussion.

but there does seem to be an issue with a popup inside a modal. hmmm.....

capellic’s picture

@jlyon, I am using your forked version and am still getting the 200 message in the alert. The contents of the 200 alert is the newly created node, so it feels like the modal isn't "catching" what Drupal returns?

In hook_modal_paths:

$paths['node/add/feedback'] = array(
    'style' => 'node-add',
    'redirect' => 'control-panel',
  );

What other parameters might I need to send in to get this to work?

capellic’s picture

I figured out the reason for my problem in #9. I am using Panels. And I have Panels controlling my edit forms. For this reason the 'page callback' value is page_manager_node_add instead of node_add.

Looking at the code in ctools_automodal_menu_alter(), I see that the it's anticipated node_add as well as some others, but not page_manager_node_add.

Even if I don't have Panels managing the node form I'm trying to use, simply having the page manager enabled for node_edit will throw it off.

SocialNicheGuru’s picture

does it still not work with panels as in #10?