You are here

public function WizardFactory::getWizardForm in Chaos Tool Suite (ctools) 8.3

Get the wizard form.

Parameters

FormWizardInterface $wizard: The form wizard.

array $parameters: The array of default parameters specific to this wizard.

bool $ajax: Whether or not this wizard is displayed via ajax modals.

Return value

array Return array form.

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;
}