You are here

public static function WebformLocationBase::getCompositeElements in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformLocationBase.php \Drupal\webform\Element\WebformLocationBase::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

1 call to WebformLocationBase::getCompositeElements()
WebformLocationBase::processWebformComposite in src/Element/WebformLocationBase.php
Processes a composite webform element.

File

src/Element/WebformLocationBase.php, line 45

Class

WebformLocationBase
Provides a webform base element for a location element.

Namespace

Drupal\webform\Element

Code

public static function getCompositeElements(array $element) {
  $elements = [];
  $elements['value'] = [
    '#type' => 'textfield',
    '#title' => t('Address'),
    '#attributes' => [
      'class' => [
        'webform-location-' . static::$name,
      ],
    ],
  ];
  $attributes = static::getLocationAttributes();
  foreach ($attributes as $name => $title) {
    $elements[$name] = [
      '#title' => $title,
      '#type' => 'textfield',
      '#error_no_message' => TRUE,
      '#attributes' => [
        'data-webform-location-' . static::$name . '-attribute' => $name,
      ],
    ];
  }
  return $elements;
}