Add a #field_parents property to element in CustomFieldWidgetBase

Created on 21 June 2025, 14 days ago

Problem/Motivation

We can reduce code in various widgets by passing down the form array parents structure as a property on the element. This can be used for unique name keys for ajax buttons, limit_validation_errors, wrapper ids, etc...

In CustomFieldWidgetBase, add the logic for:

$parents = $form['#parents'];
    $field_parents = array_merge($parents, [$field_name, $delta, $field->getName()]);

And then set it as a property value on the element:

'#field_properties' => $field_parents

Audit widgets where this can be adopted and reduce unnecessary code.

πŸ“Œ Task
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apmsooner

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

Comments & Activities

Production build 0.71.5 2024