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

On duplicate form re-generate slug #703

Merged
merged 5 commits into from
Feb 14, 2025
Merged
Changes from 3 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
9 changes: 9 additions & 0 deletions api/app/Http/Controllers/Forms/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,16 @@ public function duplicate($id)

// Create copy
$formCopy = $form->replicate();
// generate new slug before changing title
if (Str::isUuid($formCopy->slug)) {
$formCopy->slug = Str::uuid();
} else {
$formCopy->slug = null; // Reset the slug first
$formCopy->save(); // Save to ensure we have an ID
$formCopy->generateSlug(); // Now generate the slug
}
$formCopy->title = 'Copy of ' . $formCopy->title;
$formCopy->removed_properties = [];
$formCopy->save();

return $this->success([
Expand Down
Loading