You are here

public static function WebformAddressLoqate::getCompositeElements in Loqate 2.x

Same name and namespace in other branches
  1. 8 modules/pca_webform/src/Element/WebformAddressLoqate.php \Drupal\pca_webform\Element\WebformAddressLoqate::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

modules/pca_webform/src/Element/WebformAddressLoqate.php, line 65

Class

WebformAddressLoqate
Provides a Webform element for an address element.

Namespace

Drupal\pca_webform\Element

Code

public static function getCompositeElements(array $element) {
  $drupal_translation = \Drupal::translation();
  $elements = [];
  $elements['address'] = [
    '#type' => 'textfield',
    '#title' => $drupal_translation
      ->translate('Address'),
  ];
  $elements['address_2'] = [
    '#type' => 'textfield',
    '#title' => $drupal_translation
      ->translate('Address 2'),
  ];
  $elements['city'] = [
    '#type' => 'textfield',
    '#title' => $drupal_translation
      ->translate('City/Town'),
  ];
  $elements['region'] = [
    '#type' => 'textfield',
    '#title' => $drupal_translation
      ->translate('Region'),
  ];
  $elements['state_province'] = [
    '#type' => 'select',
    '#title' => $drupal_translation
      ->translate('State/Province'),
    '#options' => 'state_province_names',
    '#empty_option' => '',
  ];
  $elements['postal_code'] = [
    '#type' => 'textfield',
    '#title' => $drupal_translation
      ->translate('Zip/Postal Code'),
  ];
  $elements['country'] = [
    '#type' => 'select',
    '#title' => $drupal_translation
      ->translate('Country'),
    '#options' => 'country_names',
    '#empty_option' => '',
  ];
  return $elements;
}