Repeater access current $record

Hi guys, I can not figure out a way to access current record outside of repeater schema:
Section::make('Collected information')->schema([
Repeater::make('allClientData')
->label('Data Points')
->deletable(fn($record) => auth()->user()->team_id === $record->team_id)
->relationship()
->schema([
Select::make('client_data_type_id')
->disabled(fn($record) => auth()->user()->team_id === $record->team_id)
->options(ClientDataType::all()->sortBy('sort')->pluck('name', 'id'))
->label('Type')
->required(),

Textarea::make('value')
->label('Notes')
])
->addActionLabel('Add note')
->defaultItems(0)
->grid(2),
])->collapsible()->collapsed(),
Section::make('Collected information')->schema([
Repeater::make('allClientData')
->label('Data Points')
->deletable(fn($record) => auth()->user()->team_id === $record->team_id)
->relationship()
->schema([
Select::make('client_data_type_id')
->disabled(fn($record) => auth()->user()->team_id === $record->team_id)
->options(ClientDataType::all()->sortBy('sort')->pluck('name', 'id'))
->label('Type')
->required(),

Textarea::make('value')
->label('Notes')
])
->addActionLabel('Add note')
->defaultItems(0)
->grid(2),
])->collapsible()->collapsed(),
Inside schema $record works outside of it it does not. Thank you for havinga look!
4 Replies
aurawindsurfing
aurawindsurfingOP12mo ago
Also $state returns all of the repeater records and not the current one
Dennis Koch
Dennis Koch12mo ago
Try $livewire->record or ->getRecord()
aurawindsurfing
aurawindsurfingOP12mo ago
No it gets only the parent record. Actually I do not think it is possible as Reapeter a component that has array of fields in it. So for instance ->deletable() applies to the whole component and not the displayed field. I would probably need to change the json to normal relation to have this functionality
lucianosnchz
lucianosnchz12mo ago
Hello, did you find a solution?
Want results from more Discord servers?
Add your server