I have a modal form that should start a batch process on submit. It does not, but I get an AJAX HTTTP 200 error with many
@import url("http://localhost/modules/system/system.base.css?maxa1.n");
-like lines instead.

Without the modal the form works fine, the batch completes.

Comments

czigor’s picture

Is modal supposed to work together with batch at all?

merlinofchaos’s picture

Honestly it's not something I have ever tried. Since the modal submits via AJAX but the batch is expecting a normal submission and then redirects to the batch page to handle the patch, I can see where this might not work and would take some extra handling to work properly.

rj’s picture

For anyone researching this, one option is to redirect the batch after it's finished through your callback in $batch['finished'] as the very last step.

trim108’s picture

It's because batch_process() function uses drupal_goto by default. You may do the following:

1. form submit:

batch_set($batch);
batch_process(NULL, 'batch', 'mymodule_batch_url');
$form_state['redirect'] = $_SESSION['my_batch_url'];

2. mymodule_batch_url():

function mymodule_batch_url($batch_url, $options) {
  $_SESSION['my_batch_url'] = array($batch_url, $options);
}
bradydowling’s picture

Issue summary: View changes

I tried using the implementation you suggested trim108, but it didn't actually perform the batch operation for me. It just closed the modal. Right now I can only get one thing to happen, either the window closes or the function works. I can't get both to happen. In the past, I altered my submit function so I didn't actually need to perform a batch operation but now I don't have a choice.

albertski’s picture

@trim108 Do you by any chance have a full example or know for sure that this is possible.

darrenwh’s picture

Status: Active » Postponed (maintainer needs more info)

Can full replication steps be added please?

pankaj.g’s picture

When I try with Ctool modal, it throws error as below.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_my_module_batch_operation' not found or invalid function name in _batch_process() (line 284 of /var/www/html/icss/includes/batch.inc).

Even function _my_module_batch_operation is exists in same module file.

selfsimilar’s picture

If this is still an issue for anyone, I'm pretty sure I've got a good work-around based on #4 by trim108.

ldopchev’s picture

If anyone is still looking for the answer, @trim108 #4 works like a charm.

stox’s picture

Hey guys

I can't get this to work either, anyone have a working example they could share?

mustanggb’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)