Help Needed with ToggleButtons in Filament Form
Hi everyone,
I'm struggling with an issue that I believe (and hope) has a simple solution. I have a custom Livewire component where I'm using the Filament 3 form.
The problem lies with the ToggleButtons. As you can see, I have 5 options. The first 4 (obbligazionaria, prudente, moderata, azionaria) can be selected freely, but they exclude the last one (libera) and vice versa.
I would like to disable "libera" as soon as one of the other 4 is clicked, and disable the other 4 as soon as "libera" is clicked.
I'm pretty sure this can be done. I've tried several methods, but none have worked properly. Could you help me out? Thanks!
12 Replies
Anyone? 😦
->disableOptionWhen(fn (string $value): bool => $value === 'published')
yeah it will
https://filamentphp.com/docs/3.x/forms/fields/toggle-buttons#disabling-specific-options
Ye i tried with this method but coudn't work as excepted 😦
Why?
I'm trying, im gonna paste the code asap. Thanks for help
Sorry but im not understanding how to use this function:
This code is disabling 'obbligazionaria', 'prudente','moderata', 'azionaria' by default..
and trying with something like result in:
as you can see "libera" is disabled by default
Pump
So build a function instead of an arrow function. And condition if value = x return true, for each option.
Something like that:
(still not working)
I have some doubts this is the right method to accomplish what i need :/
try this
you also need the ->live() to work
the $state is the current array of options
ow I used a Forms\Components\CheckboxList for testing in my project
@Tally You have saved me from days of futile attempts. I don't know how to thank you! Thank you so much.
It is working perfectly fine 🙂 ❤️
you're welcome 🙏🏻