Improve support for Link field widgets

Created on 13 October 2022, about 2 years ago
Updated 21 July 2023, over 1 year ago

Problem/Motivation

This module provides a hook_maxlength_widget_settings() that allows any module to add support for their field widgets however the support for Link field widgets is limited due to hard coded detection for only "link_default" (core module) and "linkit" (contrib module) in maxlength_field_widget_form_alter(). Any other link widget will not have its widget form altered even though it implements hook_maxlength_widget_settings().

Steps to reproduce

  • Create a custom link widget that extends \Drupal\link\Plugin\Field\FieldWidget\LinkWidget
  • In a custom module, implement hook_maxlength_widget_settings
    function YOUR_CUSTOM_MODULE_maxlength_widget_settings() {
      return [
        'your_custom_link_widget' => [
          'maxlength_setting' => TRUE,
          'summary_maxlength_setting' => FALSE,
          'truncate_setting' => TRUE,
        ],
      ];
    }
    
  • Add a link field to a test content type
  • Configure the content type's Form Display:
    - Set the custom link widget for the link field.
    - Configure a maxlength for the link widget - example: 40 characters.
  • Create a new node for the test content type
  • Edit the link field title.
  • Results:
    Current with Bug: The link field title input IS NOT limited to 40 characters by the maxlength module.
    EXPECTED: The link field title input IS limited to 40 characters by the maxlength module.

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
✨ Feature request
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States recrit

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024