F
Filament15mo 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())
->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())
->hidden(fn ($context) => $context === 'create' || someLogicReturningABool())
...
Jump to solution
2 Replies
Solution
Patrick Boivin
Patrick Boivin15mo ago
I think you can inject a $context parameter in the magic closure:
->hidden(fn ($context) => $context === 'create' || someLogicReturningABool())
->hidden(fn ($context) => $context === 'create' || someLogicReturningABool())
*
*OP15mo ago
Oh, I didn't know about $context. This does exactly what I want, thank you!
Want results from more Discord servers?
Add your server