class BatchTestSimpleForm
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php \Drupal\batch_test\Form\BatchTestSimpleForm
- 10 core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php \Drupal\batch_test\Form\BatchTestSimpleForm
- 8.9.x core/modules/system/tests/modules/batch_test/src/Form/BatchTestSimpleForm.php \Drupal\batch_test\Form\BatchTestSimpleForm
Generate form of id batch_test_simple_form.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\batch_test\Form\BatchTestSimpleForm extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of BatchTestSimpleForm
1 string reference to 'BatchTestSimpleForm'
- batch_test.routing.yml in core/
modules/ system/ tests/ modules/ batch_test/ batch_test.routing.yml - core/modules/system/tests/modules/batch_test/batch_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ batch_test/ src/ Form/ BatchTestSimpleForm.php, line 13
Namespace
Drupal\batch_test\FormView source
class BatchTestSimpleForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'batch_test_simple_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['batch'] = [
'#type' => 'select',
'#title' => 'Choose batch',
'#options' => [
'batch_0' => 'batch 0',
'batch_1' => 'batch 1',
'batch_2' => 'batch 2',
'batch_3' => 'batch 3',
'batch_4' => 'batch 4',
'batch_6' => 'batch 6',
'batch_7' => 'batch 7',
],
'#multiple' => TRUE,
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
batch_test_stack(NULL, TRUE);
foreach ($form_state->getValue('batch') as $batch) {
$function = '_batch_test_' . $batch;
batch_set($function());
}
$form_state->setRedirect('batch_test.redirect');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.