Replies: 1 comment 1 reply
-
How much work is your button/JavaScript doing? Is it copying the value directly in the form? Or just triggering an Ajax request to your controller action? What do you want to happen if the user is already editing a provisional draft with other unsaved changes? Would you want all unsaved changes to be applied to the canonical entry? And what if they press the button without having made any unsaved changes (so no provisional draft)? Is creating a provisional draft important, or just that the field value gets copied? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a custom controller that copies the value of one field to another. I have it setup as a button in the sidebar of an entry using
EVENT_DEFINE_SIDEBAR_HTML
.If I make a change to the field, save the entry and then run my controller, the value is copied successfully. However, I would like to do it on click. If make a change then run trigger my controller I get 'Recent changes to the Current revision have been merged into this draft.' but the change isn't saved (and the field is still marked as changed.)
I thought of saving the entry once before copying my data:
But that doesn't make any difference.
I tried
Craft::$app->drafts->applyDraft($entry);
as well, but with that I getGetting unknown property: craft\elements\Entry::draftNotes
Is there any easy way to run my controller -> apply the provisional draft changes to the entry -> do my data copying -> resave the entry?
I hope it makes sense, but let me know if anything is unclear.
Beta Was this translation helpful? Give feedback.
All reactions