Provide a way to deprecate form API array value keys

Created on 15 April 2025, 14 days ago

Problem/Motivation

From 📌 ConfirmFormInterface::getFormName() serves no purpose in ConfirmFormBase Active :

I discussed with @longwave - the thing that's tricky here is that we are only removing this because it is dead code but the value is still being used by contrib and these modules will break silently because the deprecation we're adding here is only for the method. The current implementation will break modules using $form_state->getValue('confirm') immediately. Obviously form arrays are not part of the BC promise - see https://www.drupal.org/about/core/policies/core-change-policies/frontend... - but I think we can/should do better. I think we should consider adding a #deprecated key to the form arrays so we can issue a deprecation when calling $form_state->getValue() for a specific key. I think doing this would allow us to remove old stuff like this and get modules to update without breaking stuff.

Steps to reproduce

Proposed resolution

One thing to consider is that $form_state->getValue() can be passed nested keys as arguments, so the implementation of #deprecated might need to account for that.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

forms system

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024