function FormWizardBase::buildForm

Same name in other branches
  1. 8.x-3.x src/Wizard/FormWizardBase.php \Drupal\ctools\Wizard\FormWizardBase::buildForm()

Overrides FormInterface::buildForm

File

src/Wizard/FormWizardBase.php, line 256

Class

FormWizardBase
The base class for all form wizard.

Namespace

Drupal\ctools\Wizard

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $cached_values = $form_state->getTemporaryValue('wizard');
    // Get the current form operation.
    $operation = $this->getOperation($cached_values);
    $form = $this->customizeForm($form, $form_state);
    
    /** @var \Drupal\Core\Form\FormInterface $formClass */
    $formClass = $this->classResolver
        ->getInstanceFromDefinition($operation['form']);
    // Pass include any custom values for this operation.
    if (!empty($operation['values'])) {
        $cached_values = array_merge($cached_values, $operation['values']);
        $form_state->setTemporaryValue('wizard', $cached_values);
    }
    // Build the form.
    $form = $formClass->buildForm($form, $form_state);
    if (isset($operation['title'])) {
        $form['#title'] = $operation['title'];
    }
    $form['actions'] = $this->actions($formClass, $form_state);
    return $form;
}