Skip to content

Beautiful Open-Source Form Builder

Fix matrix condition checker to handle missing keys in field value

Cursor Agent9308ae0dd705
diff --git a/api/app/Service/Forms/FormLogicConditionChecker.php b/api/app/Service/Forms/FormLogicConditionChecker.php
index 1f3906e5a..229243b01 100644
--- a/api/app/Service/Forms/FormLogicConditionChecker.php
+++ b/api/app/Service/Forms/FormLogicConditionChecker.php
@@ -116,11 +116,16 @@ class FormLogicConditionChecker
if (!isset($condition['value'])) {
return false;
}
+ if (!is_array($fieldValue)) {
+ return false;
+ }
foreach ($condition['value'] as $key => $value) {
- if (!(array_key_exists($key, $condition['value']) && array_key_exists($key, $fieldValue))) {
- return false;
+ // Skip rows that don't exist in the field value
+ if (!array_key_exists($key, $fieldValue)) {
+ continue;
}
+ // If any row matches, return true (contains semantics)
if ($condition['value'][$key] == $fieldValue[$key]) {
return true;
}
@@ -133,7 +138,14 @@ class FormLogicConditionChecker
if (!isset($condition['value'])) {
return false;
}
+ if (!is_array($fieldValue)) {
+ return false;
+ }
foreach ($condition['value'] as $key => $value) {
+ // Check if the key exists in the field value before comparing
+ if (!array_key_exists($key, $fieldValue)) {
+ return false;
+ }
if ($condition['value'][$key] !== $fieldValue[$key]) {
return false;
}