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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

apmsooner created an issue. See original summary.

apmsooner’s picture

Status: Active » Fixed

  • apmsooner committed a5eacdc4 on 3.1.x
    Issue #3531545 by apmsooner: Add a #field_parents property to element in...
apmsooner’s picture

Assigned: apmsooner » Unassigned
apmsooner’s picture

Status: Fixed » Closed (fixed)