F
Filament14mo ago
yeonjih

Get the sum of 2 values.

Please help me regarding adding of 2 inputtext value. Thank you for response.
8 Replies
LeandroFerreira
LeandroFerreira14mo ago
Do you have two inputs and want to show the sum in another input?
yeonjih
yeonjih14mo ago
yes,
Iliyas M
Iliyas M14mo ago
If u share ur form schema here, then it will be easy to give a quick solution.
LeandroFerreira
LeandroFerreira14mo ago
take a look
TextInput::make('input_a')
->numeric()
->default(0)
->lazy(),
TextInput::make('input_b')
->numeric()
->default(0)
->lazy(),
Placeholder::make('total')
->content(fn ($get) => $get('input_a') + $get('input_b'))
TextInput::make('input_a')
->numeric()
->default(0)
->lazy(),
TextInput::make('input_b')
->numeric()
->default(0)
->lazy(),
Placeholder::make('total')
->content(fn ($get) => $get('input_a') + $get('input_b'))
yeonjih
yeonjih14mo ago
I want to multiply the price by its quantity
yeonjih
yeonjih14mo ago
Thank you for the response
toeknee
toeknee14mo ago
->content(fn ($get) => $get('input_a') + $get('input_b')) to ->content(fn ($get) => (int)$get('item_quantity') * (float)$get('item_price'))
LeandroFerreira
LeandroFerreira14mo ago
In addition, check this section. You can use injected arguments to do what you want https://filamentphp.com/docs/2.x/forms/advanced#using-closure-customization
Filament
Advanced - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
Want results from more Discord servers?
Add your server