You are here

public function WebformCardsConvertForm::buildForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_cards/src/Form/WebformCardsConvertForm.php \Drupal\webform_cards\Form\WebformCardsConvertForm::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

modules/webform_cards/src/Form/WebformCardsConvertForm.php, line 26

Class

WebformCardsConvertForm
Form for converting wizard pages to cards.

Namespace

Drupal\webform_cards\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, WebformInterface $webform = NULL) {
  $form['#title'] = $this
    ->t('Convert @title wizard pages to cards', [
    '@title' => $webform
      ->label(),
  ]);
  $form['webform_id'] = [
    '#type' => 'value',
    '#value' => $webform
      ->id(),
  ];
  $form['warning'] = [
    '#type' => 'webform_message',
    '#message_message' => $this
      ->t('Please make sure to test the converted webform on a staging server before using cards in production.'),
    '#message_type' => 'warning',
  ];
  $form['description'] = [
    '#markup' => '<p>' . $this
      ->t('Cards provide an almost identical user experience to wizard pages, but moving between cards is much faster. Cards use JavaScript for pagination and client-side validation. Cards also support auto-forwarding with conditional logic.') . '</p>' . '<p><em>' . $this
      ->t('Please note: More complex webform elements may still require server-side validation.') . '</em></p>',
  ];
  $form['hr'] = [
    '#markup' => '<p><hr/></p>',
  ];
  $form['confirm'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t("Please confirm that you want to convert this webform's wizard pages to cards"),
    '#required' => TRUE,
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Convert'),
    '#button_type' => 'primary',
  ];
  return $form;
}