The below error is thrown when adding/editing a composite.

Notice: Undefined index: key in Drupal\webform_composite\Form\WebformCompositeForm->validateForm() (line 129 of /var/www/supportcenter/web/modules/contrib/webform_composite/src/Form/WebformCompositeForm.php) #0

It looks like the relevant line does not check that key exists however its expected that its an input. I have to look into which elements and why this does not exist.

CommentFileSizeAuthor
#2 undefined_index_key-2937085-2.patch682 bytessergiu stici

Comments

richgerdes created an issue. See original summary.

sergiu stici’s picture

StatusFileSize
new682 bytes

I fixed the issue, here is the patch.

sergiu stici’s picture

Status: Active » Needs review
jrockowitz’s picture

I just ran into this issue and the attached patch works as expected.

jungle’s picture

+++ b/src/Form/WebformCompositeForm.php
@@ -126,7 +126,7 @@ class WebformCompositeForm extends EntityForm {
       if (isset($keys[$key])) {

Should we change the next line to if ($key !== NULL && isset($keys[$key])?

jungle’s picture

+++ b/src/Form/WebformCompositeForm.php
@@ -126,7 +126,7 @@ class WebformCompositeForm extends EntityForm {
+      $key = isset($value['key']) ? $value['key'] : NULL;

BTW, it's possible to use the null coalescing operator ??

$key = $value['key'] ?? NULL;

See https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op

leeomara’s picture

I also just ran into this issue and the attached patch works as expected.

richgerdes’s picture

Status: Needs review » Fixed

Thanks for the patch and review!

Since the null coalescing operator was added in 7.0, and php 5.6 was EOL over a years ago, I think its safe to use it. I've committed a version of the patch using the `??`.

This has been committed and released in 1.0-beta3.

Status: Fixed » Closed (fixed)

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