hook_form_alter() and hook_nodeapi() to alter fields and insert additional data on insert
Solutions
As mentioned in the comments any extra fields you add to to a node form won't automatically be persisted to the database, the node module only takes care of the fields that it knows about.
Traditionally there are 2 options:
- Use CCK instead and add fields to the node that way. Then you don't need to take care of data storage/loading yourself.
Add your own table for data storage using
hook_schema()
, making sure you have a column fornid
(node id). Then inhook_nodeapi()
use theinsert
andupdate
ops to run adb_query()
to insert/update the data in that table for the current node.Then you just need to load that data back from the DB on to the
$node
object in theload
op ofhook_nodeapi()
. Your data will then be available at$node->field_name
when you have a node object loaded withnode_load()
.