By mscdex on
I'm creating a custom node module and have run into a bit of a problem. In my submit handler, is there a way to store info to the node being created? I need to transfer some information from the submit handler to my hook_insert function. However my submit handler only has $form and $form_state as parameters, no $node. What is the best way to go about doing this?
Comments
No suggestions?
No suggestions?
more details?
I don't really understand what you're trying to do.
If you have a form within the module where you defined your content type this should call node_save() which will call hook_insert() automatically if the node is new. Or you can use hook_update() if the node has been edited.
Ciao
I have some data generated
I have some custom (not an existing form field) data generated in the submit handler for my custom node type's form. I need to use this generated information in mymodule_insert() when I save to the database. If a FormsAPI submit function signature provided for a $node parameter, I could simply just do $node->somedata = "foo"; and then access $node->somedata in mymodule_insert(). But since I do not have such direct access to the node in a FormsAPI submit handler, I cannot figure how to transfer this information to make it accessible when I go to insert the node into the database.
Here's an example:
I hope that makes more sense.
I'm not above doing
I'm not above doing something like this:
The life expectency of $somedata is exactly one page. It gets killed every page, so any 'global's are just widely scoped page scoped variables.