You are here

public function WebformTermsOfService::form in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformTermsOfService.php \Drupal\webform\Plugin\WebformElement\WebformTermsOfService::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 Checkbox::form

File

src/Plugin/WebformElement/WebformTermsOfService.php, line 103

Class

WebformTermsOfService
Provides a 'terms_of_service' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $form['element']['title']['#description'] = $this
    ->t('In order to create a link to your terms, wrap the words where you want your link to be in curly brackets.');
  $form['terms_of_service'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Terms of service settings'),
  ];
  $form['terms_of_service']['terms_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Terms display'),
    '#options' => [
      WebformTermsOfServiceElement::TERMS_MODAL => $this
        ->t('Modal'),
      WebformTermsOfServiceElement::TERMS_SLIDEOUT => $this
        ->t('Slideout'),
    ],
  ];
  $form['terms_of_service']['terms_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Terms title'),
  ];
  $form['terms_of_service']['terms_content'] = [
    '#type' => 'webform_html_editor',
    '#title' => $this
      ->t('Terms content'),
    '#required' => TRUE,
  ];
  return $form;
}