0

我正在学习批处理操作 api。我尝试使用表单创建批处理操作,这是我的 hook_form

function batch_form_get_form($form, &$form_state){
  $form = array();

  $form['select'] = array(
    '#title' => 'Select',
    '#type' =>'select',
    '#options' => array(
      'batch1' => 'Batch 1',
      'batch2' => 'Batch 2',
    ),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit'
  );
  return $form;
}

这是我的表单提交功能

function batch_form_get_form_submit($form,&$form_state){
  $function = 'batch_process_form';
  $_SESSION['http_request_count'] =0;
  $batch = $function;
  batch_set($batch);
  dsm ($function);
}

这是我在 batch_set 函数上使用的批处理函数

function batch_process_form(){
for($i=0; $i<10; $i++){
  $operations[] = array('batch_operation_result',array($i));
}
  $title = "Batch Started";
  $init_message = "Initialing Batch";
  $progress_message = "Work in Progress";

  $batch = array(
    'operations' => $operations,
    'title' => $title,
    'init_message' => $init_message,
    'progress_message' => $progress_message,
  );
  return $batch;
}

当我尝试运行批处理时,出现以下错误

Fatal error: Unsupported operand types in /home/dina/static/d7/includes/form.inc on line 4396 

在 form.inc 的第 4396 行

  $batch_set = $init + $batch_definition + $defaults;

我不知道我错过了什么

4

1 回答 1

1

我想你错过了一件事。

在您的提交功能中,而不是

$批处理 = $函数;

尝试

$批处理 = $函数();

祝你好运

于 2013-08-08T12:36:50.273 回答