You are here

function hook_webform_element_configuration_form_alter in Webform 6.x

Same name and namespace in other branches
  1. 8.5 webform.api.php \hook_webform_element_configuration_form_alter()

Perform alterations before a webform element configuration form is populated.

Parameters

array $form: Nested array of form elements that comprise the webform element properties.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

See also

webform_example_element_properties.module

2 functions implement hook_webform_element_configuration_form_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

webform_example_element_properties_webform_element_configuration_form_alter in modules/webform_example_element_properties/webform_example_element_properties.module
Implements hook_webform_element_configuration_form_alter().
webform_icheck_webform_element_configuration_form_alter in modules/webform_icheck/webform_icheck.module
Implements hook_webform_element_configuration_form_alter().
1 invocation of hook_webform_element_configuration_form_alter()
WebformElementBase::buildConfigurationForm in src/Plugin/WebformElementBase.php
Form constructor.

File

./webform.api.php, line 99
Hooks related to Webform module.

Code

function hook_webform_element_configuration_form_alter(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {

  /** @var Drupal\webform_ui\Form\WebformUiElementEditForm $form_object */
  $form_object = $form_state
    ->getFormObject();
  $element_plugin = $form_object
    ->getWebformElementPlugin();

  // Make sure the element has the 'custom_data' property.
  if (!$element_plugin
    ->hasProperty('custom_data')) {
    return;
  }
  $form['custom_properties'] = [
    '#type' => 'details',
    '#title' => t('Custom properties'),
    '#description' => t('The below custom properties are provided and managed by the webform_test_custom_properties.module.'),
    '#open' => TRUE,
    // Add custom properties after all fieldset elements, which have a
    // weight of -20.
    // @see \Drupal\webform\Plugin\WebformElementBase::buildConfigurationForm
    '#weight' => -10,
  ];
  $form['custom_properties']['custom_data'] = [
    '#type' => 'textfield',
    '#title' => t('Custom data'),
    '#description' => t("The custom data value will be added to the \$element's render array attributes."),
  ];
}