The referenced entity (proc: ******* (1)) does not exist

Created on 5 March 2024, 4 months ago
Updated 9 May 2024, about 2 months ago

Problem/Motivation

When encrypting a field with the 'Proc Entity Reference Field Widget' plugin and saving the newly created entity, I encounter the error 'The referenced proc entity does not exist' for each encrypted field.

Steps to reproduce

Generate the user’s encryption keys (/web/proc/generate-keys)

Create a new content entity with encrypted fields (/web/node/add)

Fill in the required fields, and encrypt (select the checkbox) for each encrypted field.

Save the content entity.

Read the error message: The referenced entity (proc: ******* (1)) does not exist.

Proposed resolution

I've done some code tweaking in order to fix, in particular at the validation method in the the widget plugin:

  public function validate($element, FormStateInterface $form_state) {
    if (!isset($form_state->getValue($element['#proc-settings']['proc_field_name'])[0]['target_id'])) {
      return;
    }

    if (empty($form_state->getValue($element['#proc-settings']['proc_field_name'])[0]['target_id'])) {
      $form_state->setValueForElement($element, [0]);
    }

    $target_id = $form_state->getValue($element['#proc-settings']['proc_field_name'])[0]['target_id'];
    if ($target_id === '*******') {
       $target_id = $element['target_id']['#default_value']->id();
    }

    $form_state->setValueForElement($element, ['target_id' =>  $target_id]);
  }
πŸ› Bug report
Status

Fixed

Version

10.1

Component

Documentation

Created by

πŸ‡΅πŸ‡ΉPortugal fcertal

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024