What the title says.
Original report:
Problem/Motivation
In the configuration form (/admin/config/people/saml), when save the form. The following PHP warning message occured.
Warning: Undefined array key "#default_value" in Drupal\samlauth\Element\MultiValue::processMultiValue() (line 190 of modules/contrib/samlauth/src/Element/MultiValue.php).
Steps to reproduce
- Install this module in a Drupal 10 website which is running with PHP 8.1
- Go to the configuration form (/admin/config/people/saml)>/li>
- Fill in all mandatory fields in the form.
- Save the form.
Proposed resolution
Change the line at 190 in src/Element/MultiValue.php
from
if (!$element['#default_value'] && isset($element['#add_empty']) && $element['#add_empty'] === FALSE) {
to
if (empty($element['#default_value']) && isset($element['#add_empty']) && $element['#add_empty'] === FALSE) {
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Patchfile.patch | 1.13 KB | vishal choudhary |
Issue fork samlauth-3352286
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
mingsongComment #4
mingsongComment #5
vishal choudharyI have added a new patch to fixed these errors.
Comment #7
roderikChecked both patches. Tested. Patch #5 is wrong:
$element['#default_value']is an empty array on initial form load, so introducing!isset()changes behavior. (The screen shows 0 empty elements.) It also has unwanted whitespace changes.I'm committing this, but not closing the issue, because there is more to do here:
This issue remains open to at least unify our own MultiValue.php with the patch, so that we don't lose any changes when we start depending on multivalue_form_element. (Or to track that we don't lose changes, in another way.)
Comment #8
roderikComment #11
joelpittetThis looks fixed from #9