F
Filament8mo ago
HL

How can I conditionally disable a custom input field?

If I do this:
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<x-filament::input.wrapper :disabled=$isDisabled()>
<x-filament::input type="text" :disabled=$isDisabled() />
...
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<x-filament::input.wrapper :disabled=$isDisabled()>
<x-filament::input type="text" :disabled=$isDisabled() />
...
$isDisabled() always returns true and the field is disabled, either if I use:
CopyableTextInput::make('loginname')
->disable(),
CopyableTextInput::make('loginname')
->disable(),
or
CopyableTextInput::make('loginname')
CopyableTextInput::make('loginname')
2 Replies
samran2000
samran20008mo ago
try to use disabledOn() function you can read this furtheer here:- https://github.com/filamentphp/filament/discussions/2739 You can callback a function in this also
GitHub
How to disable field in Edit Form of simple resource · filamentphp ...
I have created a simple resource and want to disable a field only in the edit form. I have tried the following and it is not working. use Filament\Resources\Pages\Page; use Filament\Resources\Pages...
HL
HLOP8mo ago
The issue is in the view file, I have to conditionally assign a value to the disabled attribute like this: :disabled=$isDisabled() The problem is, that $isDisabled() is always true for some reason, even if i try
CopyableTextInput::make('loginname')
->isDisabled(false),
CopyableTextInput::make('loginname')
->isDisabled(false),
or
CopyableTextInput::make('loginname')
->disabled(false),
CopyableTextInput::make('loginname')
->disabled(false),
There is no way to conditionally disable my custom field, it stays on whatever is hard coded in the view file, can't pass data to it to disable it (can pass other data like state or placeholder etc.)
Want results from more Discord servers?
Add your server