public static function WebformAddress::getCompositeElements in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Element/WebformAddress.php \Drupal\webform\Element\WebformAddress::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/ WebformAddress.php, line 22
Class
- WebformAddress
- Provides a webform element for an address element.
Namespace
Drupal\webform\ElementCode
public static function getCompositeElements(array $element) {
$elements = [];
$elements['address'] = [
'#type' => 'textfield',
'#title' => t('Address'),
];
$elements['address_2'] = [
'#type' => 'textfield',
'#title' => t('Address 2'),
];
$elements['city'] = [
'#type' => 'textfield',
'#title' => t('City/Town'),
];
// Any webform options prefixed with 'state_province' will automatically
// be included within the Composite Element UI.
// @see \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::getCompositeElementOptions
$elements['state_province'] = [
'#type' => 'select',
'#title' => t('State/Province'),
'#options' => 'state_province_names',
];
$elements['postal_code'] = [
'#type' => 'textfield',
'#title' => t('ZIP/Postal Code'),
];
// Any webform options prefixed with 'country' will automatically
// be included within the Composite Element UI.
// @see \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::getCompositeElementOptions
$elements['country'] = [
'#type' => 'select',
'#title' => t('Country'),
'#options' => 'country_names',
];
return $elements;
}