For a custom component, I want to incorporate a way of keeping track of changes made to records in specific tables.
For example, when the mileage value of a car is changed, the record having the old mileage record is being copied to an archive table before the actual record is being changed.
I envisioned the following solution. I copied the table holding the current mileage information (same columns). Currently, I have the views, models and controllers setup to access the records through the backend component. Clicking an individual record opens the edit screen and the mileage can be changed. So far so good.
But this is where the magic should start happening. When I change a mileage record and click save I want to have a check if indeed anything has changed in the record, and when it does it should first write the record containing the old information to the archive table before saving the record.
Now I have tried playing with for example the duplicate function, trying to have a custom button call for the duplicate function and save it into a different table. I haven't been able to get this to work though and I'm struggling a bit with the routing of the data from the view to the controller and then to the model.
Is there someone who can help me with this?