function WizardFactory::getWizardForm

Same name in other branches
  1. 4.0.x src/Wizard/WizardFactory.php \Drupal\ctools\Wizard\WizardFactory::getWizardForm()

Overrides WizardFactoryInterface::getWizardForm

File

src/Wizard/WizardFactory.php, line 55

Class

WizardFactory
The wizard factory.

Namespace

Drupal\ctools\Wizard

Code

public function getWizardForm(FormWizardInterface $wizard, array $parameters = [], $ajax = FALSE) {
    $form_state = $this->getFormState($wizard, $parameters, $ajax);
    $form = $this->builder
        ->buildForm($wizard, $form_state);
    if ($ajax) {
        $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
        $status_messages = [
            '#type' => 'status_messages',
        ];
        if ($messages = $this->renderer
            ->renderRoot($status_messages)) {
            if (!empty($form['#prefix'])) {
                // Form prefix is expected to be a string. Prepend the messages to
                // that string.
                $form['#prefix'] = '<div class="wizard-messages">' . $messages . '</div>' . $form['#prefix'];
            }
        }
    }
    return $form;
}