I have a .module file that is getting quite lengthy, and I added some batch functionality to it. I put the form and batch callbacks in a separate .inc file, and added the appropriate file directive to the menu array.

I was able to get the form submission to work, but the batch api threw the error Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_my_batch_callback' not found or invalid function name in _batch_process(). I got this error until I moved the batch callbacks into the .module file.

Is it possible to put the batch callbacks into a separate include file? Or have I just done something wrong?


Actually, there is a file directive in the batch array. I found it was necessary to include drupal_get_path to fully reference the file's path.

'file' => drupal_get_path('module', 'MY_MODULE') . '/includes/my-batch.inc'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.