Skip to content

Commit 597d862

Browse files
committed
Fixed copying all Matrix entries in blocks view
1 parent 6a23db3 commit 597d862

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/fields/Matrix.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,11 @@ private function copyAction(string $type, string $entrySelector): array
994994
$view = Craft::$app->getView();
995995
$id = sprintf('action-copy-%s', mt_rand());
996996

997+
$baseInfo = Json::encode([
998+
'type' => Entry::class,
999+
'fieldId' => $this->id,
1000+
]);
1001+
9971002
$view->registerJsWithVars(fn($id, $fieldId, $entrySelector) => <<<JS
9981003
(() => {
9991004
const btn = $('#' + $id);
@@ -1010,7 +1015,17 @@ private function copyAction(string $type, string $entrySelector): array
10101015
const getEntries = () => field.find($entrySelector);
10111016
10121017
btn.on('activate', () => {
1013-
Craft.cp.copyElements(getEntries());
1018+
Craft.cp.copyElements(getEntries().toArray().map((element) => {
1019+
element = $(element);
1020+
return {
1021+
... $baseInfo,
1022+
id: element.data('id'),
1023+
draftId: element.data('draftId'),
1024+
revisionId: element.data('revisionId'),
1025+
ownerId: element.data('ownerId'),
1026+
siteId: element.data('siteId'),
1027+
};
1028+
}));
10141029
});
10151030
10161031
setTimeout(() => {

0 commit comments

Comments
 (0)