Using hook_nodeapi, I want to prevent certain fields from being saved when a node is updated. I have a simple payment form that feeds into Authorize.net, but the CC number and date should not be saved, just passed on to Authorize.net.
I can pass on the data fine. But Drupal still saves the data.
I have tried unsetting the fields in the submit and update op, neithe开发者_C百科r work. If I do it in the default case, it works, but my update fails because the data isn't available to it.
What is the correct op to remove the data from the node without interfering with the update?
I would remove the fields from the node and add them using hook form alter. That way you don't have empty field which are not being used for anything.
Edit
If you really want to use hook_nodeapi() for it use $op='presave'
"presave": The node passed validation and is about to be saved. Modules may use this to make changes to the node before it is saved to the database.
If I would want to prevent certain fields from being saved when a node is updated, I would have used hook_form_alter to remove the data that I don't want to be submitted.
More info at http://drupal.org/node/651106
精彩评论