I'm trying to create a module that manages a custom node type, following the various tutorials, etc. available here. It works mostly, but it seems that the $node object passed into my custom validate handler is incomplete. Only some of the values from the original node are present; mostly key values (nid, vid, etc.) as well as any values that might have been changed by the form. However, other values from the original node are not in the $node passed into the hook_validate/hook_submit handlers.

In my particular case, I have a node value that is a calculated value using what is entered via the form, and part of the calculation includes looking at the original value as well. I don't want to just put a hidden field in the form with the original value since obviously the user could just rewrite that to anything they wanted. Is there a canonical way to get all the original data for the $node object being modified when you are in your hook_validate or hook_submit handlers? I know I could just re-extract it from the DB myself with the nid and vid, but I also know that Drupal has it in memory already since when it gets to the hook_update later, the full $node passed to that has all it's original values present, with any changes from the sparse version in hook_submit having been merged in. It seems like there should be a way to get at that from my handlers without too much fuss. Thanks...

Comments

nezroy’s picture

Hmm... well there appears to be an undocumented second parameter passed into hook_validate (http://api.drupal.org/api/5/function/hook_validate), which contains a massive array that includes a '#node' entry that has my original node data. I can use that for now, but I am worried that it will suddenly disappear at some point since, as I said, it does not appear to be in the documentation at the moment.