Skip to content

Commit

Permalink
Relationship fieldtypes should filter out invalid IDs. Closes #1752
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Sep 21, 2020
1 parent a706eb2 commit 7f06fc6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Fieldtypes/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function augment($values)
{
$values = collect($values)->map(function ($value) {
return $this->augmentValue($value);
});
})->filter()->values();

return $this->config('max_items') === 1 ? $values->first() : $values;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fieldtypes/EntriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp(): void
/** @test */
public function it_augments_to_a_collection_of_entries()
{
$augmented = $this->fieldtype()->augment(['123', '456']);
$augmented = $this->fieldtype()->augment(['123', 'invalid', '456']);

$this->assertInstanceOf(Collection::class, $augmented);
$this->assertEveryItemIsInstanceOf(Entry::class, $augmented);
Expand Down

0 comments on commit 7f06fc6

Please sign in to comment.