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

[3.x]: Problem with Save as new entry feature #11959

Closed
jlachancekffein opened this issue Sep 16, 2022 · 5 comments
Closed

[3.x]: Problem with Save as new entry feature #11959

jlachancekffein opened this issue Sep 16, 2022 · 5 comments

Comments

@jlachancekffein
Copy link

What happened?

Description

In my opinion, there are some issues with the Save as new entry feature.

  1. If I create a new entry from an existing entry by clicking on Save as new entry, and the current entry does not pass validation, Craft displays an error message for the current entry but still create a new entry with the errors of the current entry.

  2. The status of the new entry is live. According to me, the entry should be either Disabled or Draft. Otherwise, the entry is returned directly via queries, which doesn't make sense to me. Unless I misunderstand how it works.

Steps to reproduce

  1. saves an entry correctly (without validation errors)
  2. delete the value of a required field (an asset in my case)
  3. duplicates the entry by clicking Save as new entry

Expected behavior

Prevent entry creation if current contains errors or change status for Disabled or Draft

Actual behavior

The current entry is not saved but the copy is saved with status Live

Craft CMS version

3.7.54

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@jeroenverfallie
Copy link

The same issue also occurs on Craft 4, without any visible errors.

brandonkelly added a commit that referenced this issue Sep 19, 2022
@brandonkelly
Copy link
Member

  1. If I create a new entry from an existing entry by clicking on Save as new entry, and the current entry does not pass validation, Craft displays an error message for the current entry but still create a new entry with the errors of the current entry.

Yikes, that’s definitely a bug. It also loads the edit page for the duplicated entry, despite the URL still showing the original entry’s ID.

I’ve fixed this so the new entry never gets committed to the database, and the error messages are displayed back on the original entry, for the next Craft 3 release (f822ec1).

2. The status of the new entry is live. According to me, the entry should be either Disabled or Draft. Otherwise, the entry is returned directly via queries, which doesn't make sense to me. Unless I misunderstand how it works.

That’s debatable. The current behavior is respecting what you’ve submitted in the form, including the Enabled setting. It would be weird if it respected most of the form settings (e.g. changes to the Title), but not the Enabled setting. If you want the duplicated entry to be saved as disabled, you can mark the entry as disabled, then press “Save as a new entry”, and the posted status will be respected.

That said, I do see the other side of the argument. From a workflow perspective, most people are going to duplicate the entry and then start making changes to it. We had a plan to address this for Craft 4, but unfortunately we couldn’t implement it in time for the 4.0 release. You can subscribe to #10244 for updates on it.

The same issue also occurs on Craft 4, without any visible errors.

@jeroenverfallie Craft 4 will duplicate the entry as-is, without validating it.

@brandonkelly
Copy link
Member

brandonkelly commented Sep 20, 2022

Craft 3.7.55 is out with that fix.

@brandonkelly
Copy link
Member

As of Craft 4.3 (released earlier this week), when you press “Save as a new entry” for a provisional draft (an entry with unsaved changes), the unsaved changes will automatically be discarded after the duplicate entry is created.

@brandonkelly
Copy link
Member

  1. The status of the new entry is live. According to me, the entry should be either Disabled or Draft. Otherwise, the entry is returned directly via queries, which doesn't make sense to me. Unless I misunderstand how it works.

We just addressed this for Craft 5 (#12303). Going forward, entries created via “Save as a new entry” will start off in an unpublished draft state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants