How to access the Repeater item?

Hi, I am trying to access the repeater item. ``php Forms\Components\Tabs\Tab::make(__('Reduktionen'))->schema([ Forms\Components\Repeater::make('rooms') ->label(__('Zimmer')) ->itemLabel(fn() => 'TODO') // How to access room`? ->relationship('rooms') ->addable(false) ->deletable(false) ->defaultItems(0) ->schema([...]) ]),
4 Replies
Albert Lens
Albert Lensβ€’15mo ago
You must use the $get and $get
->default(function (Get $get) {
return $get('../../merit_date');
})
->default(function (Get $get) {
return $get('../../merit_date');
})
The above code is inside a repeater. It assigns a default valu of a field called merit_date which is NOT inside the Repeater To $get the value of a field in the repeater itself it must be ../field_name or just field_name with no dots and / Hope it helps. The repeater is an array of arrays
alexanderkroneis
alexanderkroneisOPβ€’15mo ago
->itemLabel(fn(Forms\Get $get) => dd($get('*')))
->itemLabel(fn(Forms\Get $get) => dd($get('*')))
returns the top-level record. :/ when I add ../* and above it just returns null
Lara Zeus
Lara Zeusβ€’15mo ago
try
->itemLabel(fn (array $state): ?string => dd($state))
->itemLabel(fn (array $state): ?string => dd($state))
alexanderkroneis
alexanderkroneisOPβ€’15mo ago
The problem is, that room is not part of the $state and I'd like to display the rooms name. πŸ˜… huh! It seems to be? Must have done something wrong before. πŸ˜‚ Thank you
Want results from more Discord servers?
Add your server