Warning: Trying to access array offset on null in StringFormatter.php

Created on 11 August 2025, 14 days ago

Lot of warnings in watchdog:

Problem/Motivation

Warning: Trying to access array offset on null in Drupal\custom_field\Plugin\CustomField\FieldFormatter\StringFormatter->formatValue() (line 96 of /var/www/html/docroot/modules/contrib/custom_field/src/Plugin/CustomField/FieldFormatter/StringFormatter.php)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.1

Component

Code

Created by

🇮🇳India gaurav_manerkar Vasco Da Gama, Goa

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

Comments & Activities

  • Issue created by @gaurav_manerkar
  • 🇺🇸United States apmsooner

    I'm not seeing these errors. I can only suggest going into manage fields and resaving your field assuming perhaps something is out of sync in your config. Otherwise, this error should never evaluate to NULL. $allowed_values here in the code is always going to be an array and $index is either gonna return the found key or FALSE. This only suggests to me that the part that is failing for you is perhaps the 'value' key that gets stored in config. So... resave your field settings is my suggestion.

    RE: https://git.drupalcode.org/project/custom_field/-/blob/3.1.x/src/Plugin/...

Production build 0.71.5 2024