F
Filament14mo ago
Nouman

Tab file field not enabled

I have a function defined to disable the whole tab and only get enabled when certain conditions are met but file upload field is not enabled while other fields are enabled:
Tabs\Tab::make('CAS')
->icon(function (Get $get) {
return self::getCas($get('id'));
})
->schema([
Forms\Components\Group::make()
->relationship('cas')
->schema([
Forms\Components\DatePicker::make('request_date')->label('Request Date'),
Forms\Components\DatePicker::make('receive_date')->label('Receive Date'),
SpatieMediaLibraryFileUpload::make('cas')
->collection('cas')
->openable()
->downloadable()
->label('')
->columnSpan('full')
->placeholder('Upload CAS Document')
->acceptedFileTypes(['application/pdf']),

])->columns(2),
])->disabled(function (Get $get) {
$interview = $get('interview');

if ((!$interview['schedule_date'] || !$interview['mock_interview_date']
|| !$interview['official_interview_date'] || !$interview['result_date'])) {

return true;
}
}),
Tabs\Tab::make('CAS')
->icon(function (Get $get) {
return self::getCas($get('id'));
})
->schema([
Forms\Components\Group::make()
->relationship('cas')
->schema([
Forms\Components\DatePicker::make('request_date')->label('Request Date'),
Forms\Components\DatePicker::make('receive_date')->label('Receive Date'),
SpatieMediaLibraryFileUpload::make('cas')
->collection('cas')
->openable()
->downloadable()
->label('')
->columnSpan('full')
->placeholder('Upload CAS Document')
->acceptedFileTypes(['application/pdf']),

])->columns(2),
])->disabled(function (Get $get) {
$interview = $get('interview');

if ((!$interview['schedule_date'] || !$interview['mock_interview_date']
|| !$interview['official_interview_date'] || !$interview['result_date'])) {

return true;
}
}),
8 Replies
Filament
Filament14mo ago
Please read the #✅┊rules about how to format your code properly.
Nouman
NoumanOP14mo ago
anyone?
krekas
krekas14mo ago
how does that interview look? does dd($get('interview')) return anything in the disabled method?
Dennis Koch
Dennis Koch14mo ago
Shouldn't be an issue, if it works with the other fields? Might be possible that there is an issue to enable/disable SpatieMediaLibrary similar to Select.
krekas
krekas14mo ago
Maybe it just doesn't have live() who knows🤷‍♂️
Nouman
NoumanOP14mo ago
live() is not working although when i refresh the page the field then get enabled can we fix it , if the issue as you said in SpatieMediaLibrary
DrByte
DrByte14mo ago
Would it help to copy the disabled() logic into the SpatieMediaLibrary component too? Not ideal, but perhaps worth exploring.
Nouman
NoumanOP14mo ago
This also not working I have to refresh the page to get it enabled alternative solution would be to redirect page on view as it refresh the page the it is going to enable. but by default view is redirect on same edit page, and its not get enabled although other fields enabled
Want results from more Discord servers?
Add your server