Read data into repeater based on selected filed

there is a products table with mark_id if i chose the mark_id i want to fill all the products with the selected mark_id in my repeater and then save the repeater data in my packedProducts model using relationship please help me this is my code and screenshot.
Forms\Components\Select::make('mark_id')
->label('Mark')
->reactive()
->options(function () {
return Mark::whereHas('warehouse', function ($query) {
$query->where('status', 'delivered')
->whereHas('products', function ($query) {
$query->where('remaining_qty', '>', 0);
});
})->pluck('name', 'id');
})->searchable()->reactive(),

Forms\Components\Repeater::make('packed_products')
->relationship()
->reactive()
->schema(function (\Filament\Forms\Get $get) {

if (!$get('../mark_id')) {
return [Forms\Components\Placeholder::make('Select Mark First')];
}

[
Forms\Components\TextInput::make('product_name')
->required()->numeric()->reactive()->rules('numeric|gt:0')
Forms\Components\TextInput::make('quantity')
->required()->numeric()->reactive()->rules('numeric|gt:0')
Forms\Components\Placeholder::make('remaining_qty')->reactive()
];

});
Forms\Components\Select::make('mark_id')
->label('Mark')
->reactive()
->options(function () {
return Mark::whereHas('warehouse', function ($query) {
$query->where('status', 'delivered')
->whereHas('products', function ($query) {
$query->where('remaining_qty', '>', 0);
});
})->pluck('name', 'id');
})->searchable()->reactive(),

Forms\Components\Repeater::make('packed_products')
->relationship()
->reactive()
->schema(function (\Filament\Forms\Get $get) {

if (!$get('../mark_id')) {
return [Forms\Components\Placeholder::make('Select Mark First')];
}

[
Forms\Components\TextInput::make('product_name')
->required()->numeric()->reactive()->rules('numeric|gt:0')
Forms\Components\TextInput::make('quantity')
->required()->numeric()->reactive()->rules('numeric|gt:0')
Forms\Components\Placeholder::make('remaining_qty')->reactive()
];

});
No description
4 Replies
Noxo
Noxo17mo ago
You don't need to add ../ prefix here if (!$get('../mark_id')) {
Adnan Yalahow
Adnan YalahowOP17mo ago
i just realised that but still the repeater is not showing data
Noxo
Noxo17mo ago
return missed
No description
Adnan Yalahow
Adnan YalahowOP17mo ago
the components in the repeater are empty and i wanted to read data based on the selected mark_id

Did you find this page helpful?