You are here

public function WebformTermsOfService::initialize in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformTermsOfService.php \Drupal\webform\Plugin\WebformElement\WebformTermsOfService::initialize()

Initialize an element to be displayed, rendered, or exported.

Parameters

array $element: An element.

Overrides WebformElementBase::initialize

File

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

Class

WebformTermsOfService
Provides a 'terms_of_service' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function initialize(array &$element) {

  // Set default #title.
  if (empty($element['#title'])) {
    $element['#title'] = $this
      ->getDefaultProperty('title');
  }

  // Backup #title and remove curly brackets.
  // Curly brackets are used to add link to #title when it is rendered.
  // @see \Drupal\webform\Element\WebformTermsOfService::preRenderCheckbox
  $element['#_webform_terms_of_service_title'] = $element['#title'];
  $element['#title'] = str_replace([
    '{',
    '}',
  ], [
    '',
    '',
  ], $element['#title']);
  parent::initialize($element);
}