I am trying to update the value of the entry enabled field depending on a certain field value.
I am listening to the EVENT_BEFORE_SAVE
event and have it updating as such $entry->enabled = $status == 'signedOff' ? true : false;
The issue I have is, if the entry is disabled at the start, then I edit the entry so that the status field to be signedOff
, it updates the enabled value to true
and it shows the lightbox field as being on, however it does not set a post date, and the entry can't be view on the frontend.
If i then resave the entry, it gets a post date and is visible on the frontend.
It seems that it may not be doing all it needs to when updating the enabled
field to be true
on the EVENT_BEFORE_SAVE
event.
Is there something I need to call, or another way I need to achieve this for it to be done correctly?
I have other plugins which listen to the EVENT_AFTER_SAVE
event, so ideally would like to do it using EVENT_BEFORE_SAVE
, so that the entry does not have to be saved.