Skip to content

Commit

Permalink
Fix conditional visibility when relying on a toggle field being false
Browse files Browse the repository at this point in the history
  • Loading branch information
holmesadam committed Dec 19, 2024
1 parent 2a4e327 commit 67ae826
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Fields/FieldsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 67ae826

Please sign in to comment.