F
Filament17mo ago
yeonjih

Get the sum of 2 values.

Please help me regarding adding of 2 inputtext value. Thank you for response.
8 Replies
LeandroFerreira
LeandroFerreira17mo ago
Do you have two inputs and want to show the sum in another input?
yeonjih
yeonjihOP17mo ago
yes,
Iliyas M
Iliyas M17mo ago
If u share ur form schema here, then it will be easy to give a quick solution.
LeandroFerreira
LeandroFerreira17mo 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
yeonjihOP17mo ago
I want to multiply the price by its quantity
yeonjih
yeonjihOP17mo ago
Thank you for the response
toeknee
toeknee17mo ago
->content(fn ($get) => $get('input_a') + $get('input_b')) to ->content(fn ($get) => (int)$get('item_quantity') * (float)$get('item_price'))
LeandroFerreira
LeandroFerreira17mo 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