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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3544821-1.patch | 1.58 KB | jphuxley |
Issue fork domain_login_restrict-3544821
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
Comment #3
jphuxley commentedMR is done, attaching a patch against 1.2 if anyone needs it (I do!).
This is now ready to review.