Empty token value not replaced when used as link label

Created on 2 September 2024, 3 months ago

Problem/Motivation

Hi,

When a token is provided as link label in field formatter, the button is displaying token name if its value is null.
Token replacement must implement ['clear' => TRUE] option to make it work as designed : display email if label is null.

Steps to reproduce

  • Add token as link label, ex : [node:field_my_button_title]
  • The field_my_button_title must have an empty value
  • Check the display of the button

Proposed resolution

In "/src/Plugin/Field/FieldFormatter/ObfuscateFieldFormatter.php" :
replace :
$linkLabel = $token->replace($linkLabel, [$entity->getEntityTypeId() => $entity]);
by
$linkLabel = $token->replace($linkLabel, [$entity->getEntityTypeId() => $entity], ['clear' => TRUE]);

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France Striknin Lyon

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024