public static function WebformExampleComposite::getCompositeElements in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_example_composite/src/Element/WebformExampleComposite.php \Drupal\webform_example_composite\Element\WebformExampleComposite::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/
webform_example_composite/ src/ Element/ WebformExampleComposite.php, line 35
Class
- WebformExampleComposite
- Provides a 'webform_example_composite'.
Namespace
Drupal\webform_example_composite\ElementCode
public static function getCompositeElements(array $element) {
$elements = [];
$elements['first_name'] = [
'#type' => 'textfield',
'#title' => t('First name'),
];
$elements['last_name'] = [
'#type' => 'textfield',
'#title' => t('Last name'),
];
$elements['date_of_birth'] = [
'#type' => 'date',
'#title' => t('Date of birth'),
// Use #after_build to add #states.
'#after_build' => [
[
get_called_class(),
'afterBuild',
],
],
];
$elements['gender'] = [
'#type' => 'select',
'#title' => t('Gender'),
'#options' => 'gender',
// Use #after_build to add #states.
'#after_build' => [
[
get_called_class(),
'afterBuild',
],
],
];
return $elements;
}