You are here

protected static function WebformMultiple::buildElementTitle in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformMultiple.php \Drupal\webform\Element\WebformMultiple::buildElementTitle()

Build an element's title with help.

Parameters

array $element: An element.

Return value

array A render array containing an element's title with help.

1 call to WebformMultiple::buildElementTitle()
WebformMultiple::buildElementHeader in src/Element/WebformMultiple.php
Build a single element header.

File

src/Element/WebformMultiple.php, line 544

Class

WebformMultiple
Provides a webform element to assist in creation of multiple elements.

Namespace

Drupal\webform\Element

Code

protected static function buildElementTitle(array $element) {
  $title = !empty($element['#title']) ? $element['#title'] : '';
  $build = [];
  $build['title'] = [
    '#markup' => $title,
  ];
  if (!empty($element['#required']) || !empty($element['#_required'])) {
    $build['title'] += [
      '#prefix' => '<span class="form-required">',
      '#suffix' => '</span>',
    ];
  }
  if (!empty($element['#help'])) {
    $build['help'] = [
      '#type' => 'webform_help',
      '#help' => $element['#help'],
      '#help_title' => $title,
    ];
  }
  return $build;
}