foreach() argument must be of type array|object, null given

Created on 2 January 2024, over 1 year ago

Problem/Motivation

Drupal throws a warning if you try to add a paragraph set with no config.

Warning: foreach() argument must be of type array|object, null given in Drupal\paragraphs_sets\Form\ParagraphsSetForm->validateForm() (line 151 of modules\contrib\paragraphs_sets\src\Form\ParagraphsSetForm.php).

Using Drupal 10.2.0 and PHP 8.1.4

Steps to reproduce

1. Go to /admin/structure/paragraphs_set/add
2. Fill only the label and submit the form
3. Observe the error message

Proposed resolution

Add the conditional logic

Alternatively, make the config field required.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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

Comments & Activities

Production build 0.71.5 2024