3 namespace Drupal\batch_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Generate form of id batch_test_simple_form.
11 class BatchTestSimpleForm extends FormBase {
16 public function getFormId() {
17 return 'batch_test_simple_form';
23 public function buildForm(array $form, FormStateInterface $form_state) {
26 '#title' => 'Choose batch',
28 'batch_0' => 'batch 0',
29 'batch_1' => 'batch 1',
30 'batch_2' => 'batch 2',
31 'batch_3' => 'batch 3',
32 'batch_4' => 'batch 4',
46 public function submitForm(array &$form, FormStateInterface $form_state) {
47 batch_test_stack(NULL, TRUE);
49 $function = '_batch_test_' . $form_state->getValue('batch');
50 batch_set($function());
52 $form_state->setRedirect('batch_test.redirect');