Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include all page content when duplicating #46

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ public function onDuplicateObject(): array
$this->validateRequestTheme();
$type = $this->getObjectType();

$object = ObjectHelper::loadObject(
$this->theme,
$type,
trim(Request::input('objectPath'))
);
$object = $this->getObjectFromRequest();
$parentPage = null;
$parent = null;

Expand All @@ -306,9 +302,10 @@ public function onDuplicateObject(): array
}
}

$className = get_class($object);
$data = $object->toArray();
$duplicatedObject = new $className($data);
// simply clone the entire object
$duplicatedObject = clone $object;
// must remove the file name or this page will not be unique
unset($duplicatedObject->fileName);

$widget = $this->makeObjectFormWidget($type, $duplicatedObject);
$this->vars['objectPath'] = '';
Expand Down
Loading