i am trying to use activeselect in my module. i have a activeselect and a target selectbox in my form but when i change the option in the activeselect, it gives me a 404 error. maybe my activeselect_path is wrong. can anyone show me an example how to use activeselect?

Comments

Barry Pretsell’s picture

I had exactly the same problem, and have spent hours on this. I found I could get the example to work if I commented out the if clause in the example

so change

function foo_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array('path' => 'foo/activeselect',
      'title' => t('activeselect foo'),
      'callback' => 'foo_activeselect',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
    
    // Other items ...
    $items[] = array('path' => 'foo/page',
      'title' => t('foo bar'),
      'callback' => 'foo_form_page',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
  }
  
  return $items;
}

to the following by commenting out the if clause and this should get it working for you.

function foo_menu($may_cache) {
  $items = array();

//  if ($may_cache) {
    $items[] = array('path' => 'foo/activeselect',
      'title' => t('activeselect foo'),
      'callback' => 'foo_activeselect',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
    
    // Other items ...
    $items[] = array('path' => 'foo/page',
      'title' => t('foo bar'),
      'callback' => 'foo_form_page',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
//  }
  
  return $items;
}
geoff_eagles’s picture

If you're still having difficulties with activeselect I've prepared a (very) simple demo module that works on 5.x
It's at
www.keyreels.com/drupal/locations.html

Hope this is of help

Geoff

carlitos.10040’s picture

Thank you Geoff, your help was key in figuring things out.
:)

dwees’s picture

/* I don't fully understand how the parameters are actually passed maybe the new Pro Drupal book will tell me? */
function activestuff_activeselect($source, $targets, $string, $extra = NULL) {

If you have a MENU_CALLBACK assigned to a path, like node/mymodule, then if you navigate to node/mymodule/dingbat, then the word dingbat is used as a parameter for your MENU_CALLBACK function automatically. Or at least this is my understanding. Very handy, no need to examine arg().

Dave

jasan’s picture

Geoff, you saved my time!.

Many Thanks.