FilamentF
Filament3y ago
*

using hiddenOn and hidden in conjunction

Currently, there's no way of achieving this, as the last chained call will override the previous.

something like this, quite understandably will not work:
->hiddenOn('create')
->hidden(fn () => someLogicReturningABool())

What I'm trying to achieve is, hide a tab in a form on create, and on edit, have a closure to run some custom logic to hide or show it.

The only solution I can think of is duplicating the code for the hiddenOn method in the hidden closure, which is less than ideal.

Any suggestions on how to tackle this?
Solution
I think you can inject a
$context
parameter in the magic closure:
->hidden(fn ($context) => $context === 'create' || someLogicReturningABool())
Was this page helpful?