function webform_example_element_properties_webform_element_alter in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_example_element_properties/webform_example_element_properties.module \webform_example_element_properties_webform_element_alter()
Implements hook_webform_element_alter().
File
- modules/
webform_example_element_properties/ webform_example_element_properties.module, line 66 - Provides an example that shows how to add custom properties to Webform elements.
Code
function webform_example_element_properties_webform_element_alter(array &$element, FormStateInterface $form_state, array $context) {
// Add data-custom to the element's attributes.
if (!empty($element['#custom_data'])) {
$element['#attributes']['data-custom'] = $element['#custom_data'];
}
}