Node update: getting old value

I am updating node with nodeapi update, but there is more that I need to do behind the scenes, which requires me to know the old value of the field / Is there a way to get the old value before overwriting.

+4
source share
1 answer

Edit

hook_nodeapi() only affects the new $node object, so my earlier answer will not help you. Instead, you will need to access the node as it is sent. To do this, you will need to register your own submit handler, which is called when the node form is submitted. This will give you access to both current values ​​and new values:

 function test_form_alter(&$form, &$form_state, $form_id) { if ($form_id === 'contenttype_node_form') { // Replace contenttype $form['#submit'][] = 'test_submit'; // Add a submit handler } } function test_submit($form, &$form_state) { // Load the current node object $node = node_load($form_state['values']['nid']); // Display the current node object values dsm($node); // Display the submitted values dsm($form_state['values']); } 

update is called the $node object. You might be interested in a presave that validates a node after validation or a validate that validates it before validation; both $op lights before the new $node object is saved.

+2
source

All Articles