Nested Disabled Checks

Is there something wrong with doing something like this:
Section::make('Info')
->disabled(function () {
return someValue == 1;
}
->schema([
Select::make('some_other_value)
->disabled(function () {
return someOtherCheck == 1;
})
])
Section::make('Info')
->disabled(function () {
return someValue == 1;
}
->schema([
Select::make('some_other_value)
->disabled(function () {
return someOtherCheck == 1;
})
])
Basically, I'm trying to use disabled on an entire Section and then again on specific parts of that section. It's behaving very odd. I'm getting Uncaught TypeError: Cannot read properties of null (reading '__livewire') errors in the console. And the disable feature isn't working properly
10 Replies
bwurtz999
bwurtz999OP2y ago
I am using Select components and the components would only disable if I removed searchable()
LeandroFerreira
Can you share the whole code please?
bwurtz999
bwurtz999OP2y ago
Section::make('Flight Information')
->columns(2)
->disabled(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
return $flight->order->status->step >= 5;
}
return false;
})
->schema([
// ...
Select::make('extendedProps.depart_from')
->label('Depart From')
->options(Airport::orderBy('code')->pluck('code', 'id'))
->required()
->searchable(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
if($flight->order->status->step >= 5) {
return false;
}
}
return true;
})
->reactive()
->disabled(function (callable $get) {
$team = Team::find(auth()->user()->team_id);

return $team->airline == 0;
}),
// ...
Section::make('Flight Information')
->columns(2)
->disabled(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
return $flight->order->status->step >= 5;
}
return false;
})
->schema([
// ...
Select::make('extendedProps.depart_from')
->label('Depart From')
->options(Airport::orderBy('code')->pluck('code', 'id'))
->required()
->searchable(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
if($flight->order->status->step >= 5) {
return false;
}
}
return true;
})
->reactive()
->disabled(function (callable $get) {
$team = Team::find(auth()->user()->team_id);

return $team->airline == 0;
}),
// ...
bwurtz999
bwurtz999OP2y ago
Filament
FullCalendar by Saade - Plugins - Filament
The Most Popular JavaScript Calendar as a Filament Widget 💛
LeandroFerreira
what is the issue?
bwurtz999
bwurtz999OP2y ago
One issue seems to be that if the Section is disabled but I use searchable() on the Select element, the disabled is ignored Sorry the Section piece was wrong but there is still an issue. Here is an example:
Section::make('Kitchen Information')
->schema([
Select::make('extendedProps.kitchen_id')
->label('Provider')
->disabled(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
if($flight->order->status->step >= 5) {
return true;
}
}
return false;
})
Section::make('Kitchen Information')
->schema([
Select::make('extendedProps.kitchen_id')
->label('Provider')
->disabled(function (callable $get) {
$id = $get('id');
if (isset($id)) {
$flight = Flight::find($id);
if($flight->order->status->step >= 5) {
return true;
}
}
return false;
})
This disabled check works properly. But if I add ->searchable() it is no longer disabled
awcodes
awcodes2y ago
It can’t be searchable and disabled, making it searchable turns it into an alpine component and it has to be enabled for the js to interact with it.
bwurtz999
bwurtz999OP2y ago
Interesting... is there a way I can check if the component is disabled from the ->searchable() option? I want it to be searchable if it is enabled. But I also want to be able to disable it if necessary Or do I have to pick one or the other before it is rendered?
awcodes
awcodes2y ago
maybe a callback in searchable() that returns true or false based on if the $component->isDisabled()? something like this:
Select::make('test')
->disabled(fn () => true)
->searchable(fn (Select $component) => $component->isDisabled()),
Select::make('test')
->disabled(fn () => true)
->searchable(fn (Select $component) => $component->isDisabled()),
bwurtz999
bwurtz999OP2y ago
This was great thank you I forgot I could access the component with $component In my case I needed ->searchable(fn (Select $component) => !$component->isDisabled()),
Want results from more Discord servers?
Add your server