F
Filament7mo ago
Sidem

update defaultItems repeater with an other fields

Hi everyone, I need that when changing the value of a field, I can create a logic to dynamically generate several Repeater items at once, to make it easier for the user
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('numbers_of_product')
->numeric()
->minValue(1)
->live(),
Repeater::make('products')
->schema([
TextInput::make('name')
->required()
->columnSpan(2),
])
->grid(2)
->addable(false)
->deletable(false)
->defaultItems(fn (Get $get) => $get('numbers_of_product')),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('numbers_of_product')
->numeric()
->minValue(1)
->live(),
Repeater::make('products')
->schema([
TextInput::make('name')
->required()
->columnSpan(2),
])
->grid(2)
->addable(false)
->deletable(false)
->defaultItems(fn (Get $get) => $get('numbers_of_product')),
]);
}
the problem is that when i update the TextInput, the repeater defaultItems dosen't update too. Have you any idee ? Thanks !
1 Reply
Want results from more Discord servers?
Add your server