F
Filament6mo ago
Eth

retrieving previous record

I’m trying to get the price for the chosen place name but it’s retrieving the previous price -giving null for the first record- Code:
Forms\Components\Select::make('placeName')
->label('Place Name')
->required()
->live()
->searchable()
->options(Place::all()->pluck('placeName'))
->afterStateUpdated(function ($state, callable $set, callable $get){
$place = $get('placeName');
$placePrice = Place::find($place)->placePrice;
$set('totalPrice', $placePrice);
}),
Forms\Components\Select::make('placeName')
->label('Place Name')
->required()
->live()
->searchable()
->options(Place::all()->pluck('placeName'))
->afterStateUpdated(function ($state, callable $set, callable $get){
$place = $get('placeName');
$placePrice = Place::find($place)->placePrice;
$set('totalPrice', $placePrice);
}),
No description
No description
No description
2 Replies
KA
KA6mo ago
try ->options(Place::all()->pluck('placeName', 'id'))
Eth
Eth6mo ago
This is it!, thank you