How to sum in filament

I need help i have a any taxes in my project i need calculate totality of the taxes in one field total impuestos
No description
4 Replies
TranceCode
TranceCode11mo ago
can you try with something like this?
Forms\Components\TextInput::make('size')
->numeric()
->live()
->label('Altura'),
Forms\Components\TextInput::make('weight')
->label('Peso Kg.')
->numeric()
->live(debounce: 1500)
->afterStateUpdated(fn (Set $set, Get $get) => $set('imc', $get('weight') / ($get('size') * $get('size')))),
Forms\Components\TextInput::make('imc')
->label('Indice de masa corporal')
->live(),
Forms\Components\TextInput::make('size')
->numeric()
->live()
->label('Altura'),
Forms\Components\TextInput::make('weight')
->label('Peso Kg.')
->numeric()
->live(debounce: 1500)
->afterStateUpdated(fn (Set $set, Get $get) => $set('imc', $get('weight') / ($get('size') * $get('size')))),
Forms\Components\TextInput::make('imc')
->label('Indice de masa corporal')
->live(),
just replace * for + of course
Adrianryff
AdrianryffOP11mo ago
thanks for your help, but the placeholder can't storage to database
Tieme
Tieme11mo ago
Why do you need to storage to database? if you do calculations front-end someone can manipulate the value that is passing to database. For showing you can use placeholder, but to safe in database use a lifecycle hook : https://filamentphp.com/docs/3.x/panels/resources/editing-records#lifecycle-hooks
Want results from more Discord servers?
Add your server