Problem/Motivation

When adding a new Encryption Profile at admin/config/system/encryption/profiles/add without any encryption method modules installed, submitting the form correctly shows the error message:

No encryption method selected.

However, the red validation-error highlight is applied to the Encryption Key field, not the Encryption Method field — even though Encryption Method is the empty/invalid field and Encryption Key is correctly filled in. This is misleading and makes it look like the Key field is the problem, when it isn't.

Encryption Issue

Steps to reproduce

  1. Install and enable Encrypt modules
  2. Create a valid Key entity
  3. Go to admin/config/system/encryption/profiles/add.
  4. Fill in Label and select the previously created Key under Encryption Key.
  5. Leave Encryption Method empty
  6. Click Save.

Comments

dkmishra created an issue. See original summary.

gurkawal’s picture

Hi @dkmishra,

I reproduced the issue on Drupal 11.

When saving an encryption profile without selecting an encryption method, the form correctly displays:
No encryption method selected.

However, the validation error highlight was incorrectly applied to the Encryption Key field instead of the Encryption Method field. This was misleading because the key could be valid while only the encryption method was missing.

Cause:
In EncryptionProfileForm::validateForm(), all entity validation errors were being attached to encryption_key:

$form_state->setErrorByName('encryption_key', implode(';', $errors));

Fix:
The patch maps each validation error to the correct form field, such as encryption_method or encryption_key, before calling setErrorByName().

Verified after applying the patch:

Error message: No encryption method selected.
Red validation highlight appears on Encryption Method, not Encryption Key.
Tested on Drupal 11.4 with Encrypt 8.x-3.3.

gurkawal’s picture

StatusFileSize
new52.57 KB