function BatchExampleForm::submitForm
Same name in other branches
- 3.x modules/batch_example/src/Form/BatchExampleForm.php \Drupal\batch_example\Form\BatchExampleForm::submitForm()
Overrides FormInterface::submitForm
File
-
modules/
batch_example/ src/ Form/ BatchExampleForm.php, line 49
Class
- BatchExampleForm
- Form with examples on how to use cache.
Namespace
Drupal\batch_example\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Gather our form value.
$value = $form_state->getValues()['batch'];
// Set the batch, using convenience methods.
$batch = [];
switch ($value) {
case 'batch_1':
$batch = $this->generateBatch1();
break;
case 'batch_2':
$batch = $this->generateBatch2();
break;
}
batch_set($batch);
}