Drupal 7 如何在自定义表单上创建drupal批处理操作
我正在学习批处理操作api。我尝试使用表单创建批处理操作这里是我的hook_表单Drupal 7 如何在自定义表单上创建drupal批处理操作,drupal-7,Drupal 7,我正在学习批处理操作api。我尝试使用表单创建批处理操作这里是我的hook_表单 function batch_form_get_form($form, &$form_state){ $form = array(); $form['select'] = array( '#title' => 'Select', '#type' =>'select', '#options' => array( 'batch1' => 'B
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);
}
这是我的批处理函数,我在批处理集合函数中使用了它
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;
}
在form.inc.第4396行
$batch_set = $init + $batch_definition + $defaults;
我不知道我错过了什么我想你错过了一件事 在提交函数中,而不是 $batch=$function 试一试 $batch=$function()
祝你好运美元默认值变量是什么?我想您必须将其设置为#选择类型。
$batch_set = $init + $batch_definition + $defaults;