Select (native: false) disabled but user can choose options
I am using a non-native select with a disabled using a closure, the select is disabled when needed but the user can always choose between options
I am using the following code in my blade view to render the form
the definition of my form is as follow:
I will put two screenshots, the first contains the enabled select and the second is the disabled select
25 Replies
did you add the mount method with
form->fill()
?@Leandro Ferreira Yes I have this:
Please share the whole code you are trying to do..
here is the component code: https://gist.github.com/heloufir/58f39335b877a7ded91dfbbe0e10d1a6
and the blade code: https://gist.github.com/heloufir/2e94f3ba6a5ce78a70f1524135f7a496
You’re extending Page. So you need to call
parent::mount()
in your mount method.that throws an exception
This might sound silly, but are you sure, the
->disabled()
returns true?Yep, I debugged on that and I am sure, it disables the select but let the user click on the select and see the options.
But if I put true without a closure, it works the select is disabled and the user cannot click on it
So in other words
->disabled(fn() =>true)
doesnt work
->disabled(true)
worksCan you share the url for this. Something else is going on here. Page definitely has a mount method. It is a livewire component.
no, both of them works (passing true in a closure or not works) but when passing the function as a closure that does not work
It’s weird that it thinks it is the parent
it is not live, but you can see the whole code here:
the component code: https://gist.github.com/heloufir/58f39335b877a7ded91dfbbe0e10d1a6
and the blade code: https://gist.github.com/heloufir/2e94f3ba6a5ce78a70f1524135f7a496
That error screen has a share link in the top right. That’s what I’m referring too.
oh I thought you were speaking about the project sorry, here is the link: https://flareapp.io/share/353vJpo7/claim/u6uUrQyviOW1qqURquMH1KMAV8xI41Mx
Flare
Method App\Filament\Pages\AdvancedTimeRegistration::mount does not exist. - The error occurred at http://localhost:8000/app/advanced-time-registration
hmm. not sure what's going on, but this part doesn't make sense.
Method App\Filament\Pages\AdvancedTimeRegistration::mount does not exist.
it's like it thinks the parent is itself instead of Page
yep didn't understand too, I am trying to found an explanation 😅
console errors?
nope nothing
can you try in a resource on a regular form? looking at the code I think this might be a bug.
choices.js should be reading the disabled attribute on the select component. so this is strange
Do you have dependant selects, right? It doesn't happen if you remove
searchable()
, right?I will try ASAP and let you know
Yes for dependant selects, and if I remove searchable it does work
use
->searchable(fn() => !$disabled)
in the selectsyep that does the trick
it disables the select and transform it to non-searchable (so, non-native) and the user cannot click on it
thanks for the help
@awcodes @Leandro Ferreira Should I mark the post as resolved, or should I leave it to see if there is a bug?
mark it as resolved. but maybe the docs need to be updated.
thanks