Skip to content

Commit

Permalink
Merge pull request #339 from holmesadam/visibility-fix
Browse files Browse the repository at this point in the history
Fix conditional visibility when relying on a toggle field being false
  • Loading branch information
atmonshi authored Dec 24, 2024
2 parents fea3ad9 + 67ae826 commit c011d2f
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 c011d2f

Please sign in to comment.