Problem/Motivation

This is my first time using this module. Installed version 2.0.0-alpha3 on Drupal 10.2.6
I tried to create a Site Setting Type without a Group label, and when I save it gives a WSOD error:

The website encountered an unexpected error. Try again later.

TypeError: reset(): Argument #1 ($array) must be of type array, null given in reset() (line 203 of modules/contrib/site_settings/src/Form/SiteSettingEntityTypeForm.php).

Steps to reproduce

  1. Go to link /admin/structure/site_setting_entity_type
  2. click Add Site Setting Type button
  3. Label field (marked required) --- enter any label
  4. Create a new "Group" label (not marked required) --- leave blank
  5. Click Save button at bottom

Proposed resolution

It seems the resolution here depends whether or not the group label field is intended to be a required field...
from reading the documentation, a group label seemed optional and I didn't think I needed it for my use case...
However, if all site settings types should be part of a group, well then simply rendering that form field as required would fix this issue, since the error clears up when I enter a group label in that field.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

FizCS3 created an issue. See original summary.

aaron.ferris’s picture

I could be wrong, but looking at the code following the error it looks as though new_group should be required.

$new_group->set('id', $this->generateMachineName($new_group->label()));

The alternate to this would be of course to only run this block of code if new_group is populated which would avoid the WSOD, but not sure of any other consequences if we go this route.

aaron.ferris’s picture

Status: Active » Needs review
scott_euser’s picture

Status: Needs review » Needs work

Thanks both! Unfortunately it's a bit more complicated than that - new group should only be conditionally required if an existing group is not chosen. So we need to implement the validate method of form base.

Ideally we should also extend the save method on the entity itself to throw an exception if someone attempts to create a Site Setting entity programmatically without a Group.

scott_euser changed the visibility of the branch 3445275-group-label-required to hidden.

scott_euser’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.