You are here

public static function WebformName::getCompositeElements in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformName.php \Drupal\webform\Element\WebformName::getCompositeElements()

Get a renderable array of webform elements.

Parameters

array $element: A render array for the current element.

Return value

array A renderable array of webform elements, containing the base properties for the composite's webform elements.

Overrides WebformCompositeBase::getCompositeElements

File

src/Element/WebformName.php, line 22

Class

WebformName
Provides a webform element for an name element.

Namespace

Drupal\webform\Element

Code

public static function getCompositeElements(array $element) {
  $elements = [];

  // Any webform options prefixed with 'title' will automatically
  // be included within the Composite Element UI.
  // @see \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::getCompositeElementOptions
  $elements['title'] = [
    '#type' => 'webform_select_other',
    '#title' => t('Title'),
    '#options' => 'titles',
  ];
  $elements['first'] = [
    '#type' => 'textfield',
    '#title' => t('First'),
  ];
  $elements['middle'] = [
    '#type' => 'textfield',
    '#title' => t('Middle'),
  ];
  $elements['last'] = [
    '#type' => 'textfield',
    '#title' => t('Last'),
  ];
  $elements['suffix'] = [
    '#type' => 'textfield',
    '#title' => t('Suffix'),
  ];
  $elements['degree'] = [
    '#type' => 'textfield',
    '#title' => t('Degree'),
  ];
  return $elements;
}