Forgetting to set a pattern via field_group causes an 500 error when building the form's settings states

Created on 2 August 2023, over 1 year ago
Updated 27 October 2023, about 1 year ago

Hi,

Problem/Motivation

I encountered error 500 below after configuring a display mode on an entity: "TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 227 of modules/contrib/ui_patterns_settings/src/Form/SettingsFormBuilder.php)."

Steps to reproduce

My project is based on Drupal 9.5, PHP 8.1.
I use the following modules and sub-modules: UI Patterns (version 1.7) / UI Patterns Field Group / Ui Patterns Display Suite and UI Patterns Settings (2.1.0@alpha1)

1) I've added a new field group as a pattern
2) dragged my fields into the field group , I volontary forgot to configure the mappings of my fields with those of the pattern.
3) Saved.

Proposed resolution

The buildStatesForm method of the SettingsFormBuilder class checks if the states variable is other than zero, but in this case it's NULL.

I suggest the patch below to avoid a 500 error and check that the variable is not NULL.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇷🇪Réunion Martygraphie Saint-Denis (Réunion)

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

Comments & Activities

Production build 0.71.5 2024