You are here

function gdpr_fields_form_field_config_edit_form_alter in General Data Protection Regulation 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/gdpr_fields/gdpr_fields.module \gdpr_fields_form_field_config_edit_form_alter()
  2. 8 modules/gdpr_fields/gdpr_fields.module \gdpr_fields_form_field_config_edit_form_alter()

Implements hook_form_FORM_ID_alter().

@todo Check user edit permission for GDPR fields.

File

modules/gdpr_fields/gdpr_fields.module, line 18
Module file for the GDPR Fields module.

Code

function gdpr_fields_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  /** @var \Drupal\Core\Field\FieldConfigInterface $field */

  // @todo Check that target entity is a content entity.
  $field = $form_state
    ->getFormObject()
    ->getEntity();

  // Do not add GDPR settings to the GDPR Consent Agreement form.
  if ($field
    ->getType() === 'gdpr_user_consent') {
    return;
  }
  $form['field']['gdpr_fields'] = [
    '#type' => 'details',
    '#title' => t('GDPR field settings'),
    '#open' => TRUE,
  ];
  GdprFieldSettingsForm::buildFormFields($form['field']['gdpr_fields'], $field
    ->getTargetEntityTypeId(), $field
    ->getTargetBundle(), $field
    ->getName());
  $form['actions']['submit']['#submit'][] = 'gdpr_fields_form_field_config_edit_form_submit';
}