By nancydru on
I want to be able to use "node/add/-type-" to create multiple nodes. But hook_submit is allegedly gone (although it is still in the APIs). I can use a submit handler, as suggested in the conversion page, but then I'd have to run through all the possible add-on form elements (like taxonomy, etc.) to build the base node. In 5.x hook_submit was presented with a base node and modifying the few values for each additional one was easy. How might one do this in 6.x?
Comments
current thinking
I'm currently thinking that I can move most of my old hook_submit code to hook_insert where a completely build node is given. Then I can loop through building new nodes that I can use with node_save.
Does hook_insert get driven if op=preview?
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
...
There's now hook_nodeapi($op=='presave').
(Are you asking how to convert $form_state['values'] into $node? Drupal does
$node = node_form_submit_build_node($form, $form_state);. BTW, there's nothing much sophisticated here: the code basically casts $form_state['values'] into an object and you get... $node.)====
But here's an alternative suggestion:
I had a look at the module. Since, in "import" mode, you don't want Drupal itself to save the node (because it's a dummy node used only for inputting a mass of text for import; you're creating some derived nodes yourself), then you don't need the normal node creation flow. You can remove all the buttons ("Save", "Preview") and put an "Import" one instead, whose "#submit" would point to, say, "quotes_import_submit". In this submit handler you do
$node = node_form_submit_build_node($form, $form_state);) and continue as usual with your import code.Bless you
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru