You are here

function gdpr_fields_form_field_config_edit_form_submit 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_submit()
  2. 8 modules/gdpr_fields/gdpr_fields.module \gdpr_fields_form_field_config_edit_form_submit()

Form submission handler for gdpr_fields_form_field_config_edit_form_alter.

This version of the GDPR fields form is embedded on the standard field settings page.

Parameters

array $form: The form array.

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

Throws

\Drupal\Core\Entity\EntityStorageException

1 string reference to 'gdpr_fields_form_field_config_edit_form_submit'
gdpr_fields_form_field_config_edit_form_alter in modules/gdpr_fields/gdpr_fields.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function gdpr_fields_form_field_config_edit_form_submit(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Field\FieldConfigInterface $field */
  $field = $form_state
    ->getFormObject()
    ->getEntity();
  $entity_type = $field
    ->getTargetEntityTypeId();
  $config = GdprFieldConfigEntity::load($entity_type);
  if (NULL === $config) {
    $config = GdprFieldConfigEntity::create([
      'id' => $entity_type,
    ]);
  }
  $field_config = new GdprField([
    'bundle' => $field
      ->getTargetBundle(),
    'name' => $field
      ->getName(),
    'entity_type_id' => $entity_type,
  ]);
  $field_config
    ->setEnabled($form_state
    ->getValue('gdpr_enabled'))
    ->setRta($form_state
    ->getValue('gdpr_rta'))
    ->setRtf($form_state
    ->getValue('gdpr_rtf'))
    ->setAnonymizer($form_state
    ->getValue('gdpr_anonymizer'))
    ->setNotes($form_state
    ->getValue('gdpr_notes'));
  $config
    ->setField($field_config);
  $config
    ->save();
}