Get the sum of 2 values.

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

Did you find this page helpful?