Problem/Motivation

When editing a Domain record (for example /admin/config/domain/edit/[domain machine name]), if you have not yet saved the form you will see the following error:

Warning: foreach() argument must be of type array|object, null given in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 113 of /var/core/www/core/lib/Drupal/Core/Render/Element/Checkboxes.php).:

This is because the default value for the checkbox fields in domain_login_restrict_form_alter() is returning NULL, as per \Drupal\Core\State\StateInterface::get, and we're passing that directly in to '#default_value'.

Steps to reproduce

On a fresh Drupal installation, install the module and add some Domains. Edit the domain before saving to see the error (make sure you have error reporting set appropriately to see warnings).

Proposed resolution

If we just add a check for the value from State and print an empty array if it is NULL it should resolve this.

Remaining tasks

I'll create an MR/patch now, so it will need reviewing.

CommentFileSizeAuthor
#3 3544821-1.patch1.58 KBjphuxley
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

jphuxley created an issue. See original summary.

jphuxley’s picture

Assigned: jphuxley » Unassigned
Status: Active » Needs review
StatusFileSize
new1.58 KB

MR is done, attaching a patch against 1.2 if anyone needs it (I do!).

This is now ready to review.

  • 62643361 committed on 8.x-1.x
    #3544821 Updating default for checkboxes on domain edit form to fix...