You are here

public function WebformCard::form in Webform 8.5

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

modules/webform_cards/src/Plugin/WebformElement/WebformCard.php, line 109

Class

WebformCard
Provides a 'card' element.

Namespace

Drupal\webform_cards\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['card'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Card settings'),
  ];
  $form['card']['title_tag'] = [
    '#type' => 'webform_select_other',
    '#title' => $this
      ->t('Title tag'),
    '#description' => $this
      ->t("The card's title HTML tag."),
    '#options' => [
      'h1' => $this
        ->t('Header 1 (h1)'),
      'h2' => $this
        ->t('Header 2 (h2)'),
      'h3' => $this
        ->t('Header 3 (h3)'),
      'h4' => $this
        ->t('Header 4 (h4)'),
      'h5' => $this
        ->t('Header 5 (h5)'),
      'h6' => $this
        ->t('Header 6 (h6)'),
      'label' => $this
        ->t('Label (label)'),
    ],
  ];
  $form['card']['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 card.') . '<br /><br />' . $this
      ->t('Defaults to: %value', [
      '%value' => $webform
        ->getSetting('wizard_prev_button_label', TRUE),
    ]),
  ];
  $form['card']['next_button_label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Next page button label'),
    '#description' => $this
      ->t('This is used for the Previous button on the card.') . '<br /><br />' . $this
      ->t('Defaults to: %value', [
      '%value' => $webform
        ->getSetting('wizard_next_button_label', TRUE),
    ]),
  ];
  $form['form']['display_container']['title_display']['#options'] = [
    'none' => $this
      ->t('None'),
    'invisible' => $this
      ->t('Invisible'),
  ];
  return $form;
}