Skip to content

Commit b33ab12

Browse files
committed
add backwards compatibility
1 parent 04beb27 commit b33ab12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Concerns/HasSelectableValues.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ protected static function buildRelationshipOptions(mixed $field): array
131131
continue;
132132
}
133133

134-
$opts = $results->pluck($relation['relationValue'] ?? 'name', $relation['relationKey'])->toArray();
134+
// Fallback to model's primary key for existing records that don't have relationKey set
135+
$relationKey = $relation['relationKey'] ?? $model->getKeyName();
136+
$opts = $results->pluck($relation['relationValue'] ?? 'name', $relationKey)->toArray();
135137

136138
if (count($opts) === 0) {
137139
continue;

0 commit comments

Comments
 (0)