Allow hook_maxlength_widget_settings to override existing widget settings

Created on 4 July 2023, over 1 year ago
Updated 5 July 2023, over 1 year ago

Problem/Motivation

hook_maxlength_widget_settings does not allow the original settings to be overridden. There are cases where the original settings need to be altered. For example, enforcing a hard character limit on link text when using the linkit widget.

Steps to reproduce

In a custom module implement the hook:

function hook_maxlength_widget_settings() {
  return [
    'linkit' => [
      'maxlength_setting' => TRUE,
      'summary_maxlength_setting' => FALSE,
      'truncate_setting' => TRUE,
    ],
  ];
}

The code joins the original settings array with the array returned by the hook using + which does not overwrite the values.

Proposed resolution

Use array_merge or equivalent when returning the original settings and hook provided array.

Remaining tasks

  • ❌Get maintainer approval for the proposed resolution
  • ❌Implement resolution
  • ❌Write test coverage (contact a maintainer if you need help)
  • ❌Maintainer review via the UI
  • ❌Maintainer Code Review #1
  • ❌Maintainer code review #2
  • ❌Merge into dev branch, with credit to author and participants

User interface changes

API changes

Data model changes

Feature request
Status

Needs review

Version

2.1

Component

Code

Created by

🇬🇧United Kingdom minirobot London

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

Comments & Activities

Production build 0.71.5 2024