D Terminal Dev
D Terminal Dev
FFilament
Created by D Terminal Dev on 6/21/2024 in #❓┊help
Show item preview when repeater item is collapsed
is it possible if an item is collapsed, instead of showing a blank row, to show some preview data of the collapsed item?
3 replies
FFilament
Created by D Terminal Dev on 6/21/2024 in #❓┊help
Refresh repeater values when value outside repeater changes
I have this TVA field and when its udpated I want the values inside the repeater to refresh, change etc... ``` Forms\Components\TextInput::make('tva')->live()->label('TVA')->afterStateUpdated(function($get, $set){ foreach ($get('products') as $key => $data){ $set("products/$key/qty", $data['qty']); } })->numeric()->default(0), Repeater::make('products')->label('Produse') ->columnSpan('2') ->live() ->schema([ Forms\Components\Select::make('product')->label('Produs')->searchable()->relationship('products', 'name')->required()->createOptionForm([ TextInput::make('name'), TextInput::make('unit'), TextInput::make('price_per_unit'), ])->createOptionUsing(function ($data) { return auth()->user()->products()->create($data); })->columnSpan(2)->live()->afterStateUpdated(function ($state, $set) { $produs = Product::find($state); $set('unit', $produs->unit); $set('ppu', $produs->price_per_unit); }), TextInput::make('qty')->label('Cantitate')->live()->afterStateUpdated(function ($state, $set, $get) { $produs = Product::find($get('product')); $curr = $get('../../moneda'); $tva = $get('../../tva'); if (!$produs) return; $set('unit', $produs->unit); $set('ppu', $produs->price_per_unit); $total_no_vat = (int)$state * $produs->price_per_unit; $total_with_vat = $tva ? Number::currency($total_no_vat * ((double)("1.".$tva)), $curr) : Number::currency($total_no_vat, $curr); $total_vat = $tva ? Number::currency($total_no_vat * ((double)("1.".$tva)), $curr) : Number::currency(0, $curr); $set('total_price_no_vat', Number::currency($total_no_vat, $curr)); $set('total_price_vat',$total_with_vat); $set('total_vat',$total_vat); })->required()->columnSpan(1),
4 replies