BatchTestMockForm.php in Drupal 10
File
core/modules/system/tests/modules/batch_test/src/Form/BatchTestMockForm.php
View source
<?php
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class BatchTestMockForm extends FormBase {
public function getFormId() {
return 'batch_test_mock_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['test_value'] = [
'#title' => t('Test value'),
'#type' => 'textfield',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
batch_test_stack('mock form submitted with value = ' . $form_state
->getValue('test_value'));
}
}