I tried adding active select boxes into a page_node_form (node add/edit form for page content type) and I just get a white screen.
What I did to test whether or not activeselect would work in a hook_form_alter function is take the working example from API.txt of activeselect, and copy it into my custom module, except declaring the form elements in hook_form_alter for forms with $form_id == 'page_node_form'.
It appears when the callback is getting triggered to create the activeselect box when on the add/edit page of the page content type, it immediately sees the exit() function and is stopping execution of the entire node/edit page, not just the AJAX callback. If I remove the exit() functions out of the script, I noticed that the form element with '#type' => 'activeselect' element doesn't even output a select box, which leads me to believe that FAPI doesn't know about the activeselect element defined in hook_elements of the activeselect module. Although the following returns true in the hook_form_alter.
$activeselect = module_exists('activeselect');
The category module defines an active select in a hook_form_alter, but for some reason it doesn't stop the execution of the page and just give me a blank white page, like my implementation. The activeselect module currently isn't working correctly with category, but at least it is not giving a blank white screen. What could be the issue here?
Comments
Comment #1
tom friedhof commentedThe category_form_alter I mentioned above is actually only being used when dealing with distant parents, which I am not, so I don't know for sure if category module is working with the activeselect element in its hook_form_alter, or if it's getting the white screen of death. The activeselect that category uses on its category add/edit page is declared in a standard drupal_get_form FAPI array. Does any one know of any other working modules that use activeselect through a hook_form_alter function?
Also the link above for activeselect currently not working with category module is http://drupal.org/node/121524
Comment #2
tom friedhof commentedActive Select works fine in the hook_form_alter. I had another issue going on completely unrelated to the module.
For the record, you should never have a theme named the same as a module. For instance lets say I created a module called tomf and I created a theme called tomf. The situation I ran into was my callback for the activeselect was named tomf_activeselect. Well, when you define an element with hook_elements() you can theme that element with a theme function called theme_activeselect. Theme functions can be overridden with your theme name, so I could overide that theme function in template.php with tomf_activeselect. Since I had already declared that function as my activeselect callback, drupal was seeing that as a theme function and ran it to format the element.
Just a PEBCAK bug, not a bug with drupal or the activeselect module.
There is nothing stopping you from naming a theme the same as a module, it's just not beneficial if you do, and you'll more than likely run into problems if you do.