F
Filament17mo ago
Zakhaev

AfterStateUpdate looks like it isnt working

Grid::make(2)->schema([
Select::make('chosen_asset')
->label('Selecteer aan middel')
->searchable()
->options(
Asset::all()->map(function ($asset) {
return [
'id' => $asset->id,
'value' => $asset->name . ' - ' . $asset->brand,
];
})->pluck('value', 'id')->toArray()
)
->afterStateUpdated(
fn (Closure $set, $value) => $set('asset_id', $value)
)
]),

Grid::make(2)->schema([
TextInput::make('asset_id')
->label('Type'),
Grid::make(2)->schema([
Select::make('chosen_asset')
->label('Selecteer aan middel')
->searchable()
->options(
Asset::all()->map(function ($asset) {
return [
'id' => $asset->id,
'value' => $asset->name . ' - ' . $asset->brand,
];
})->pluck('value', 'id')->toArray()
)
->afterStateUpdated(
fn (Closure $set, $value) => $set('asset_id', $value)
)
]),

Grid::make(2)->schema([
TextInput::make('asset_id')
->label('Type'),
As you can see in the example above. I have a chosen asset select component. With values of assets. That is working fine. But when some value is selected i want to change other fields according to that. I try to change the asset_id field below but nothing seems to be working. Can anyone help me with this?
4 Replies
cheesegrits
cheesegrits17mo ago
Add reactive() to it.
Zakhaev
ZakhaevOP17mo ago
Thank you bro, its working now. But the $value gives problem, seems like that value cant be accesed. Do you know how i can get the value of the chosen option?
Zakhaev
ZakhaevOP17mo ago
Thanks guys problem is solved.
Want results from more Discord servers?
Add your server