Problem/Motivation

When configuring the Views Link field formatter, the "Trim link text length" UI prompts you to "Leave blank to allow unlimited link text lengths." However, the field validation will not allow blank values.

UI conflict

Proposed resolution

looking at core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php

    $elements['trim_length'] = array(
      '#type' => 'number',
      '#title' => t('Trim link text length'),
      '#field_suffix' => t('characters'),
      '#default_value' => $this->getSetting('trim_length'),
      '#min' => 1,
      '#description' => t('Leave blank to allow unlimited link text lengths.'),
    );
 

Suggestions that the 'min' value is at odds with the blank requirement?

Remaining tasks

Update the code so that a blank value doesn't trigger the validation routine.

User interface changes

None recommended

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Screenack created an issue. See original summary.

Version: 8.2.1 » 8.2.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.2.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)
Issue tags: -link, -views formatter +Bug Smash Initiative
FileSize
10.02 KB

Just tried to reproduce this. It does throw this error if you enter '0' in the field, which makes sense as you can't trim to 0. It works if you actually leave the field blank.