dynamic repeater fields names

Hello, is it possible to make the repeater fields names dynamic? something like:
Repeater::make('recuperare_invoire')
->label('Recuperare Invoire')
->schema([
Grid::make(3)->schema([
DatePicker::make('data_recuperare_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Data Recuperare ' . (intval(str_replace('.', '', $statePath)) + 1))
->required()
->native(false),

TextInput::make('recuperare_ore_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Numar de Ore ' . (intval(str_replace('.', '', $statePath)) + 1))
->default(2)
->numeric()
->step(0.5)
->required(),

TextInput::make('recuperare_interval_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Interval Recuperare ' . (intval(str_replace('.', '', $statePath)) + 1))
->required(),
]),
])
Repeater::make('recuperare_invoire')
->label('Recuperare Invoire')
->schema([
Grid::make(3)->schema([
DatePicker::make('data_recuperare_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Data Recuperare ' . (intval(str_replace('.', '', $statePath)) + 1))
->required()
->native(false),

TextInput::make('recuperare_ore_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Numar de Ore ' . (intval(str_replace('.', '', $statePath)) + 1))
->default(2)
->numeric()
->step(0.5)
->required(),

TextInput::make('recuperare_interval_invoire'.$numberOfRepeaterItem)
->label(fn ($get, $statePath) => 'Interval Recuperare ' . (intval(str_replace('.', '', $statePath)) + 1))
->required(),
]),
])
2 Replies
Lara Zeus
Lara Zeus2mo ago
ya, this should work TextInput::make('recuperare_ore_invoire'.$numberOfRepeaterItem) as long as its unique and its string
Atreides
Atreides2mo ago
@Lara Zeus that wasnt the question, the question is, how can we set the $numberOfRepeaterItem to the actual item key @jamesro I think this could be, what you are searching for: https://discord.com/channels/883083792112300104/1147995447332438077
Want results from more Discord servers?
Add your server