How to add Cancel button to Batch operation? Is this even possible?


There is no good way to interrupt a batch process, afaik. There used to be a hackish trick in Drupal 6 though, see http://drupal.org/node/894222. Maybe if you can figure out how that worked, you can make Drupal 7 do the same.


Define your operation like this:

$batch = array(
  'title' => t('Exporting'),
  'operations' => array(
    array('my_function_1', array($account->uid, 'story')),
    array('my_function_2', array()),
  'finished' => 'my_finished_callback',
  'file' => 'path_to_file_containing_myfunctions',


  • 1
    That doesn't add a cancel button, it's just a standard batch definition – Clive Mar 26 '13 at 16:11

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.