Hi,
I've created a module that allows me to create a correlation between two types of nodes on my site. What I'd like to do is in the form for node type 'A' is create a pop-up box that allows me to choose a relationship from node type 'B' doing some type of search through all the created nodes of type 'B'. Then when I've selected a node, have that selection be reflected back on my original form.

I've gotten started on it as you can see below, but my first issue is that with modal dialogues, I can't get the dialogue to open to my menu item that I've defined ('relation_ab/search')..it always opens simply to 'node/add'. I've tried it with other paths as well to no avail.

Am I going about this properly?

So far what I've got:

in the function that creates the form:

$form['relation_ab']['button'] = array(
    '#type' => 'button',
    '#value' => t('Add a relationship'),
    '#weight' => 15,
    '#ahah' => array(
      'path' => 'relation_ap/add',
      'event' => 'click',
      'method' => 'append',
      'wrapper' => 'relation_ab',
      'progress' => array('type' => 'throbber'),
    ),
  ); 

Then in my ahah call back function:

function relation_ab_add() {
  $data = '<script type="text/javascript">var modalOptions = {url: "relation_ab/search", autoFit:true}; 
Drupal.modalFrame.open(modalOptions)</script>';
  $GLOBALS['devel_shutdown'] =  FALSE;
  print drupal_to_js(array('status' => TRUE, 'data' => $data));

  //pause and do all the fancy here

  //drupal_json(array('data' => $data));
  exit;

}

Comments

jaypan’s picture

Unfortunately, AHAH callback functions don't really work like that. They are not the same as regular javascript callback functions, there is a certain pattern for doing it.

http://drupal.org/node/331941

Contact me to contract me for D7 -> D10/11 migrations.