From 67ae82620676f517c6f95e925e2e7de0890daed3 Mon Sep 17 00:00:00 2001 From: Adam Holmes Date: Thu, 19 Dec 2024 14:19:32 +0000 Subject: [PATCH] Fix conditional visibility when relying on a toggle field being false --- src/Fields/FieldsContract.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Fields/FieldsContract.php b/src/Fields/FieldsContract.php index 1bb85206..e76d5f3d 100644 --- a/src/Fields/FieldsContract.php +++ b/src/Fields/FieldsContract.php @@ -138,6 +138,11 @@ public function appendFilamentComponentsOptions($component, $zeusField, bool $ha } $relatedFieldArray = Arr::wrap($get('zeusData.' . $relatedField)); + + // In the example where a field is only visible when the related field is NOT checked, + // we need to convert booleans to strings for in_array comparison + $relatedFieldArray = array_map(fn($value) => is_bool($value) ? ($value ? 'true' : 'false') : $value, $relatedFieldArray); + if (in_array($relatedFieldValues, $relatedFieldArray)) { return true; }