You are here

public function WebformWizardPage::form in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformWizardPage.php \Drupal\webform\Plugin\WebformElement\WebformWizardPage::form()

Gets the actual configuration webform array to be built.

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 An associative array contain the element's configuration webform without any default values.

Overrides ContainerBase::form

File

src/Plugin/WebformElement/WebformWizardPage.php, line 106

Class

WebformWizardPage
Provides a 'webform_wizard_page' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  /** @var \Drupal\webform\WebformInterface $webform */
  $webform = $form_state
    ->getFormObject()
    ->getWebform();
  $form['wizard_page'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Page settings'),
  ];
  $form['wizard_page']['prev_button_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Previous page button label'),
    '#description' => $this
      ->t('This is used for the Next Page button on the page before this page break.') . '<br /><br />' . $this
      ->t('Defaults to: %value', [
      '%value' => $webform
        ->getSetting('wizard_prev_button_label', TRUE),
    ]),
  ];
  $form['wizard_page']['next_button_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Next page button label'),
    '#description' => $this
      ->t('This is used for the Previous Page button on the page after this page break.') . '<br /><br />' . $this
      ->t('Defaults to: %value', [
      '%value' => $webform
        ->getSetting('wizard_next_button_label', TRUE),
    ]),
  ];

  // Wizard pages only support visible or hidden state.
  $form['conditional_logic']['states']['#multiple'] = FALSE;
  return $form;
}