F
Filament15mo ago
Crater

problems with Repeater default array from a Select

Hello, I have this script that is failing, dafault always returns null or []
1 Reply
Crater
CraterOP15mo ago
Forms\Components\Select::make('purchase_request_id')
->afterStateUpdated(function (callable $get, callable $set) {
$listItems = PurchaseOrderItem::where('order_id', $get('purchase_request_id'))->get();
$set('items', $listItems);
})->reactive(),

Forms\Components\Repeater::make('items')
->schema([...])
->default(function (callable $get) {
$data = $get('items');
return $data;
})

// out: null
Forms\Components\Select::make('purchase_request_id')
->afterStateUpdated(function (callable $get, callable $set) {
$listItems = PurchaseOrderItem::where('order_id', $get('purchase_request_id'))->get();
$set('items', $listItems);
})->reactive(),

Forms\Components\Repeater::make('items')
->schema([...])
->default(function (callable $get) {
$data = $get('items');
return $data;
})

// out: null
->default(function (callable $get) it's right?
Want results from more Discord servers?
Add your server