BatchTestChainedForm.php in Zircon Profile 8.0
File
core/modules/system/tests/modules/batch_test/src/Form/BatchTestChainedForm.php
View source
<?php
namespace Drupal\batch_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class BatchTestChainedForm extends FormBase {
public function getFormId() {
return 'batch_test_chained_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['value'] = array(
'#type' => 'textfield',
'#title' => 'Value',
'#default_value' => 1,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
$form['#submit'] = array(
'Drupal\\batch_test\\Form\\BatchTestChainedForm::batchTestChainedFormSubmit1',
'Drupal\\batch_test\\Form\\BatchTestChainedForm::batchTestChainedFormSubmit2',
'Drupal\\batch_test\\Form\\BatchTestChainedForm::batchTestChainedFormSubmit3',
'Drupal\\batch_test\\Form\\BatchTestChainedForm::batchTestChainedFormSubmit4',
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
}
public static function batchTestChainedFormSubmit1($form, FormStateInterface $form_state) {
batch_test_stack(NULL, TRUE);
batch_test_stack('submit handler 1');
batch_test_stack('value = ' . $form_state
->getValue('value'));
$value =& $form_state
->getValue('value');
$value++;
batch_set(_batch_test_batch_1());
$form_state
->setRedirect('batch_test.redirect');
}
public static function batchTestChainedFormSubmit2($form, FormStateInterface $form_state) {
batch_test_stack('submit handler 2');
batch_test_stack('value = ' . $form_state
->getValue('value'));
$value =& $form_state
->getValue('value');
$value++;
batch_set(_batch_test_batch_2());
$form_state
->setRedirect('batch_test.redirect');
}
public static function batchTestChainedFormSubmit3($form, FormStateInterface $form_state) {
batch_test_stack('submit handler 3');
batch_test_stack('value = ' . $form_state
->getValue('value'));
$value =& $form_state
->getValue('value');
$value++;
$form_state
->setRedirect('batch_test.redirect');
}
public static function batchTestChainedFormSubmit4($form, FormStateInterface $form_state) {
batch_test_stack('submit handler 4');
batch_test_stack('value = ' . $form_state
->getValue('value'));
$value =& $form_state
->getValue('value');
$value++;
batch_set(_batch_test_batch_3());
$form_state
->setRedirect('batch_test.redirect');
}
}