F
Filament15mo ago
arul

how to Get $get value from another text input

I want get value for another textinput. My code TextInput::make('stok')->default(fn(Get $get) => $get('jenis_barang_id')) how to show $get('jenis_barang_id); In my textInput i want to query in default()
10 Replies
krekas
krekas15mo ago
you also need to add live()
arul
arulOP15mo ago
Yes, but still null no value .. to show in my text input
krekas
krekas15mo ago
Show more code formatted correctly in markdown. Read #✅┊rules how to do that
arul
arulOP15mo ago
This my code
No description
krekas
krekas15mo ago
Ow god 🤦‍♂️ please no screenshots. Read #✅┊rules !
arul
arulOP15mo ago
Sorry
arul
arulOP15mo ago
Gist
help GET $get in filament
help GET $get in filament. GitHub Gist: instantly share code, notes, and snippets.
arul
arulOP15mo ago
My code
Sanchit Patil
Sanchit Patil15mo ago
this might help, (not been tested).
Select::make('jenis_barang_id')
->options(StokBarang::where('aktive', 1)->pluck('nama_barang', 'id'))
->searchable()
->preload()
->required()
->live()
->afterStateUpdated(function (Forms\Set $set, ?string $state){
$val = DB::table('stok_barangs')
->select(DB::raw('stok_awal + masuk - keluar AS sisa_stok'))
->where('id', $state)->value('sisa_stok');
$set('sisa_stok', $val);
}),

TextInput::make('sisa_stok')->readOnly(),
Select::make('jenis_barang_id')
->options(StokBarang::where('aktive', 1)->pluck('nama_barang', 'id'))
->searchable()
->preload()
->required()
->live()
->afterStateUpdated(function (Forms\Set $set, ?string $state){
$val = DB::table('stok_barangs')
->select(DB::raw('stok_awal + masuk - keluar AS sisa_stok'))
->where('id', $state)->value('sisa_stok');
$set('sisa_stok', $val);
}),

TextInput::make('sisa_stok')->readOnly(),
More here: https://filamentphp.com/docs/3.x/forms/advanced#generating-a-slug-from-a-title
arul
arulOP15mo ago
Work $set thanks. Buat i wonder how to show $get() . In default().
Want results from more Discord servers?
Add your server