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

Remove ability to set root entry as parent when saving entry #3083

Closed
wants to merge 1 commit into from
Closed

Remove ability to set root entry as parent when saving entry #3083

wants to merge 1 commit into from

Conversation

notnek
Copy link
Contributor

@notnek notnek commented Jan 7, 2021

I saw several issues (and PRs) around this (#1948, #1666, #2647) through other UI bits, but nothing for using a parent field when updating an entry. Since that field is part of the publish form and isn't required, I thought in the controller made the most sense. If there's another preferred way to accomplish this, I can update.

This bit us with a client a few weeks ago, but thankfully the sorting tree UI has already been patched around this.

@jelleroorda
Copy link
Contributor

Awesome. We actually ran into this as well yesterday on our production site. Luckily it was just the CP that was broken. Like you described it's still possible to set a root page as the parent when creating/updating an entry. An alternative solution could be to create a validation error instead of silently ignoring it.

@jasonvarga
Copy link
Member

Sorry, I'm having trouble working out what situation this is fixing. Can you explain it a little more or record a video?

@notnek
Copy link
Contributor Author

notnek commented Jan 12, 2021

Sorry, I'm having trouble working out what situation this is fixing. Can you explain it a little more or record a video?

Sure @jasonvarga. Here's the situation in action. When you choose the root page as your parent when editing an entry, the structure gets updated so that your entry is a child of the root entry instead of just being moved to the root of the tree.

statamic-parent-bug.mov

@jasonvarga
Copy link
Member

Ah yes that's painfully obvious now. I tried a bunch of combinations and somehow missed that one. Thanks!

@jasonvarga jasonvarga mentioned this pull request Jan 14, 2021
@jasonvarga
Copy link
Member

Thank you for the PR but this now breaks the parent field completely.
Even if you choose a non-root as the parent, the entry will be moved to the top level.

This is because Entry::find(..) gives you an Entry object, which doesn't have an isRoot(). So, it always gets set back to null. We need to find the "page" instead. You can see how I solved this in #3104

@jasonvarga jasonvarga closed this Jan 14, 2021
@notnek notnek deleted the entryUpdateRootParent branch January 14, 2021 20:50
@notnek
Copy link
Contributor Author

notnek commented Jan 14, 2021

Thanks @jasonvarga!

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

Successfully merging this pull request may close these issues.

3 participants