The text "array" displays under the link field

Created on 15 December 2023, about 1 year ago
Updated 22 August 2024, 4 months ago

Problem/Motivation

The text "array" displays below link fields that are configured to use Field Redirect.

Steps to reproduce

  • Configure Field Redirect on a link field of a content type
  • Create a node of that content type.

Proposed resolution

TBD

Remaining tasks

  • ❌ Submit merge request fixing the bug
  • ❌ Test the fix
  • ❌ Write test coverage
  • ❌ Merge into 2.0.x-dev

User interface changes

"Array" text no longer displays.

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

2.0

Component

User interface

Created by

🇺🇸United States cedewey Denver, CO

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

Merge Requests

Comments & Activities

  • Issue created by @cedewey
  • 🇮🇳India sidharth_soman Bangalore

    I am not able to see the 'Array' text after following the steps to reproduce the bug. Could you share the configuration you used for field_redirect as well as maybe the field's configuration?

    Tested on Drupal 10.2.0 and PHP 8.1.4

  • 🇺🇸United States liberatr Portland, OR

    I have the same issue on Drupal 10, and I see an error message:
    "Warning: Array to string conversion in Drupal\field_redirect\Service\UtilityService->formAlter() (line 325 of modules/contrib/field_redirect/src/Service/UtilityService.php)."

  • 🇺🇸United States liberatr Portland, OR

    The line in question is trying to concatenate an object and an array:

    $widget['uri']['#description'] = $message . $widget['uri']['#description'];
    

    My guess is that there is some module making the #description into a render array.

    Here is a DSM of what is in that variable for me:

    array:2 [▼
      "#theme" => "item_list"
      "#items" => array:2 [▼
        0 => 
    Drupal\Core\Field
    \
    FieldFilteredMarkup {#2576 ▼
          #string: "Redirect users to this URL when clicked. If this field is blank, they will remain on the site."
        }
        1 => 
    Drupal\Core\StringTranslation
    \
    TranslatableMarkup {#2559 ▼
          #string: "
    Start typing the title of a piece of content to select it. You can also enter an internal path such as %add-node or an external URL such as %url. Enter %front t
     ▶
    "
          #arguments: array:5 [▶]
          #translatedMarkup: null
          #options: []
          #stringTranslation: 
    Drupal\Core\StringTranslation
    \
    TranslationManager {#392 ▶}
        }
      ]
    ]

    I wonder if adding this message to the beginning or end of the array would work, and if for some reason that value is not already an array, make it so:

    $widget['uri']['#description']['#items'][] = $message;
    
Production build 0.71.5 2024