You are here

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

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

Class

WebformContact
Provides a webform element for a contact element.

Namespace

Drupal\webform\Element

Code

public static function getCompositeElements(array $element) {
  $elements = [];
  $elements['name'] = [
    '#type' => 'textfield',
    '#title' => t('Name'),
  ];
  $elements['company'] = [
    '#type' => 'textfield',
    '#title' => t('Company'),
  ];
  $elements['email'] = [
    '#type' => 'email',
    '#title' => t('Email'),
  ];
  $elements['phone'] = [
    '#type' => 'tel',
    '#title' => t('Phone'),
  ];
  $elements['address'] = [
    '#type' => 'textfield',
    '#title' => t('Address'),
  ];
  $elements['address_2'] = [
    '#type' => 'textfield',
    '#title' => t('Address 2'),
  ];
  $elements['city'] = [
    '#type' => 'textfield',
    '#title' => t('City/Town'),
  ];
  $elements['state_province'] = [
    '#type' => 'select',
    '#title' => t('State/Province'),
    '#options' => 'state_province_names',
  ];
  $elements['postal_code'] = [
    '#type' => 'textfield',
    '#title' => t('ZIP/Postal Code'),
  ];
  $elements['country'] = [
    '#type' => 'select',
    '#title' => t('Country'),
    '#options' => 'country_names',
  ];
  return $elements;
}