By maik.kaskader on
Through which hooks can I track specific field value of the node which have been changed?
I want to compare each field with the old value and if it has changed to handle this.
Tried hook_form_alter - add a new field in each element of the array with the old value.
Like this:
$Form['#node'] -> field_track1 ['0'] ['old_value'] = $form['#node'] -> field_track1['0']['value'];
and then process it in hook_nodeapi. But the problem is that already comes hook_nodeapi node object and my field 'old_value' there is no more.
Perhaps there is a way to do this? How to get old and new value of each field?
Also seeking a similar solution for profile fields.
Thanks for your attention!
Comments
I'm assuming you dont want to
I'm assuming you dont want to use node revisions to do this? that said, you could always just use hook_form_alter and query the database or custom submit function to get the existing values you want to compare to.
Toronto Website Developer
Unfortunately this solution
Unfortunately this solution does not suit me
why not?
why not?
Toronto Website Developer
Because there are a lot of
Because there are a lot of problems with output. And I need to compare old value and new value when information submitting. After comparing I want to send message to Administrator.
Just to make things clear
Drupal does not keep old field values by default. But it keeps whole node state in form of node revisions. If you look inside database tables you will find that each node has vid field which is unique per nid. And as said above, you can compare different revisions.
If you need to compare newly submitted values during the time of node update there is a hook_node_update() for D7. hook_nodeapi() is for D6.
D7 module
http://drupal.org/project/track_field_changes
Mariquecalcus
TwoTravelTheWorld