Skip to content

Commit

Permalink
Merge branch '4.x' into feature/237-pasting-nested-entries-between-ed…
Browse files Browse the repository at this point in the history
…itors
  • Loading branch information
brandonkelly committed Jun 12, 2024
2 parents d401885 + 01f7603 commit 28437ac
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,10 @@ protected function prepValueForInput($value, ?ElementInterface $element, bool $s
->keyBy(fn(EntryChunk $chunk) => $chunk->entryId)
->map(fn(EntryChunk $chunk) => $chunk->getEntry())
->all();
ElementHelper::swapInProvisionalDrafts($entries);

if (!$static) {
ElementHelper::swapInProvisionalDrafts($entries);
}

$value = $chunks
->map(function(BaseChunk $chunk) use ($static, $entries) {
Expand All @@ -1046,18 +1049,22 @@ protected function prepValueForInput($value, ?ElementInterface $element, bool $s
$entry = $entries[$chunk->entryId];

try {
if (!$static) {
return Html::tag('craft-entry', options: [
'data' => [
'entry-id' => $entry->isProvisionalDraft ? $entry->getCanonicalId() : $entry->id,
'card-html' => $this->getCardHtml($entry),
],
]);
}
$cardHtml = $this->getCardHtml($entry);
} catch (InvalidConfigException) {
// this can happen e.g. when the entry type has been deleted
return '';
}

if ($static) {
return $cardHtml;
}

return Html::tag('craft-entry', options: [
'data' => [
'entry-id' => $entry->isProvisionalDraft ? $entry->getCanonicalId() : $entry->id,
'card-html' => $cardHtml,
],
]);
})
->join('');
}
Expand Down

0 comments on commit 28437ac

Please sign in to comment.