Closed FratteFlorian closed 3 years ago
The issue doesn't have enough information.
Is it possible to use the Repeater with Relation field (for BelongsToMany relation)? I'm able to handle and sync the values, but I can not populate the Relation field with saved values - it is always empty after save. Even if I replace it with Select field (with ->multiple() option) it doesn't work when used in repeater.
The relation field (with BelongsToMany relation) is populated successfully if I use it outside of the repeater, just for a single record.
The structure is as follow: Client models have many Assessment models, every Assessment model belongs to many User models
The repeater is used for Assessments. In Assessment model I have:
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
In screen query method I have:
$client->load(['assessments', 'assessments.users']);
return [
'client' => $client,
'assessments' => $client->assessments,
];
In screen layouts method I have:
return [
Layout::rows([
Repeater::make('assessments')
->layout(EditAssessmentLayout::class)
]),
];
In layout fields method I have:
Relation::make('users.')
->fromModel(User::class, 'name')
->searchColumns('surname')
->displayAppend('fullname')
->title('Assessed by')
->multiple(),
Existing values (eg. in edit form) are not populating Any idea?
KR Florian