Hi, I want to keep a record of when a field was last changed. I have a site where I want to "feature" an object (it's a publication) every couple of weeks on the front page of the site. I plan on having a group of publications that are worth featuring and rotate them. I will either flag all of the featurable publication records and have one randomly appear - if anyone can tell me how to do this I would be grateful - or I will manually change the flag on one of the papers every couple of weeks. This, I know I can do! If I manually change the flag, I optimally want to have a date field that will change to the current date every time I change the flag to "on", so I can see when the last time it was featured was. I can't figure out how to do it - can anyone help?
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi,
something like this might help...
public function onAfterWrite() {
parent::onAfterWrite();
$arrChanged = $this->getChangedFields(true,1);
//Log $arrChanged - this structure contains all information about changes made in the last write store this information where you like
}