function BatchTestMultiStepForm::buildForm
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- 
              core/modules/ system/ tests/ modules/ batch_test/ src/ Form/ BatchTestMultiStepForm.php, line 25 
Class
- BatchTestMultiStepForm
- Generate form of id batch_test_multistep_form.
Namespace
Drupal\batch_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $step = $form_state->get('step');
  if (empty($step)) {
    $step = 1;
    $form_state->set('step', $step);
  }
  $form['step_display'] = [
    '#markup' => 'step ' . $step . '<br/>',
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => 'Submit',
  ];
  // This is a POST form with multiple steps that does not transition from one
  // step to the next via POST requests, but via GET requests, because it uses
  // Batch API to advance through the steps.
  $form['#cache']['max-age'] = 0;
  return $form;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
