I have the extension working great. The issue I am trying to overcome is if you have a drop down list for example and you pulled this from another table with id being the FK value. How would I convert this to the value instead of the FK id that is being saved in the auditTrail DB table? I would like new value / old value to be, for example, Admin - User instead of 1 - 4.
If you want the semantic result of the relation you will probably need to code the extension a little.
Hmmm, I had to solve this once, I chose to do this outside of the extension within the display of the audit so that the client side changed 1 to Admin or 4 to User
sammaye, do you have what you did to solve it. The only thing I can think of to do is to findByPk on old value and set the old value to the name and not the key. The new value is easy. I added an array to the extension called relation = array(‘relation’=>array(‘relation_name.field’=>‘foreign_key’).
I am working in the LoggingeBehavior file. I was trying to store the old model into a variable beforeSave but it doesn’t seem to store the old one, just the new one.
If you look above there is a point where I actually get the old attributes. There you can take the old model and save it in its old state, however, you might alreayd be doing that and instead seeing a copy on write scenario whereby even though you assigned that “copy” of the variable to another it didn’t save the state due to copy on write.