You are here

public static function FormWebformSubmissionFormAlter::hook in General Data Protection Regulation Compliance 8

Hook.

1 call to FormWebformSubmissionFormAlter::hook()
gdpr_compliance_webform_submission_form_alter in ./gdpr_compliance.module
Implements hook_form_TYPE_alter().

File

src/Hook/FormWebformSubmissionFormAlter.php, line 16

Class

FormWebformSubmissionFormAlter
Hook hook_form_webform_submission_form_alter().

Namespace

Drupal\gdpr_compliance\Hook

Code

public static function hook(&$form, FormStateInterface $form_state, $form_id) {
  $display = FALSE;
  $config = \Drupal::config('gdpr_compliance.settings');
  if ($config
    ->get('webform-mode') == 'all') {
    $display = TRUE;
  }
  elseif ($config
    ->get('webform-mode') == 'custom') {
    $bundles = $config
      ->get('webform-bundles');
    $formkey = substr($form_id, 19, -9);
    if (isset($bundles[$formkey]) && $bundles[$formkey]) {
      $display = TRUE;
    }
  }
  if ($display) {
    FormWarning::addWarning($form);
  }
}