->afterStateUpdated( fn(Forms\Set $set, Forms\Get $get) => $set( 'total_amount', round(collect($get('items')) ->sum( fn($item) => (float) str_replace( ',', '', $item['unit_price'] ?? 0 ) ), 2) ) )
->schema([ Forms\Components\Repeater::make('items') ->relationship()// others code Forms\Components\TextInput::make('unit_price') ->label('Unit Price') ->mask(RawJs::make('$money($input)')) ->stripCharacters(',') ->numeric() ->inputMode('decimal') ->required() ]) ->afterStateUpdated( fn(Forms\Set $set, Forms\Get $get) => $set( 'total_amount', round(collect($get('items')) ->sum( fn($item) => (float) str_replace( ',', '', $item['unit_price'] ?? 0 ) ), 2) ) ) ->hiddenLabel() ->required() ->columnSpan(2), Forms\Components\Section::make() ->hiddenLabel() ->schema([ Forms\Components\TextInput::make('total_amount') ->label('Total') ->numeric() ->inputMode('decimal')// other code ]) ])
Forms\Components\Section::make('Expense Details') /// other data ->disableOptionsWhenSelectedInSiblingRepeaterItems() ->searchable(), Forms\Components\TextInput::make('unit_price') ->label('Unit Price') ->mask(RawJs::make('$money($input)')) ->stripCharacters(',') ->numeric() ->inputMode('decimal') ->required() ]) ->live(debounce: 600) ->afterStateUpdated( fn(Forms\Set $set, Forms\Get $get) => $set( 'total_amount', round(collect($get('items')) ->sum( fn($item) => (float) str_replace( ',', '', $item['unit_price'] ?? 0 ) ), 2) ) ) ->hiddenLabel() Forms\Components\Section::make() ->schema([ Forms\Components\TextInput::make('total_amount') ->label('Total') ->numeric() ->reactive() ->inputMode('decimal') ->readOnly() ->afterStateUpdated( fn($state, Forms\Set $set) => $set('total_amount', number_format((float) $state, 2)) ) ->required() ])->columnSpan(1) ])->columns(3),
https://www.nike.com/th/t/รองเท้าผู้-air-force-1-07-WrLlWX/CW2288-111?cp=11357671355_search_%7Cth%7CPMax:+TH+-+Smart+Shopping+-+Brand%7C%7CGOOGLE&gad_source=1&gbraid=0AAAAADLM_Zk46u-Ws6BnF93pFK2j4QcT2&gclid=CjwKCAjwvKi4BhABEiwAH2gcw_7jvIHZETI4DRxbYgnEU-OJKRqKfsLhXmYoGHsVNDw_tqUd6_Q5PhoCenEQAvD_BwE&gclsrc=aw.ds