Is your feature request related to a problem? Please describe.
I want the CMS to automatically set the published date for entries when an entry is published for the first time. This should be doable with the prePublish hook a handler something like:
CMS.registerEventListener({
name: "prePublish",
handler: ({entry}) => {
const now = new Date().toISOString();
let data = entry.get('data');
if (data.get('status') === 'draft') {
data = data.set('published', now);
}
return data.set('status', 'published');
}
});
But the invokePrePublishEventfunction (unlike invokePreSaveEvent) doesn't return the updated data.
Describe the solution you'd like
I'd like the prePublish hook to allow updating entry data.
Describe alternatives you've considered
I tried to think of a way to do this only using the preSave hook, but don't think it's possible.
Additional context
It would be worth considering whether all hooks (or at least all pre-hooks should be able to update data.
Is your feature request related to a problem? Please describe. I want the CMS to automatically set the published date for entries when an entry is published for the first time. This should be doable with the
prePublish
hook a handler something like:But the
invokePrePublishEvent
function (unlikeinvokePreSaveEvent
) doesn't return the updated data.Describe the solution you'd like I'd like the
prePublish
hook to allow updating entry data.Describe alternatives you've considered I tried to think of a way to do this only using the
preSave
hook, but don't think it's possible.Additional context It would be worth considering whether all hooks (or at least all
pre
-hooks should be able to update data.