Posted by Retsage on June 9, 2010 at 3:15am
Sorry, newbie question.
I've got a form_submit() file in a module I've created. I want to take what's in the $form_state['values'] and insert it into the database for specific nodes.
<?php
function lookingfor_searchform_submit($form, &$form_state){
//I want to take whatever value is available to me (say, $form_state['values']['text_search']) and create a new Story node with that information put into the body field (or anywhere, really).
}
?>Was thinking of hooking in through hook_nodeapi() but I can't figure out what case operation I would need. Kind of lost, new to programming Drupal.
Thanks for any help.
Comments
Try this function
Try this function http://api.drupal.org/api/function/drupal_execute
"A Programmer is a device for turning coffee into code!"
Another option: <?phpfunction
Another option:
<?phpfunction lookingfor_searchform_submit($form, &$form_state){
global $user;
$node = (object)array(
'type' => 'story',
'status'=> 1,
'uid' => $user->uid,
'body' => trim($form_state['values']['text_search'])),
// Populate any other fields you want here.
);
node_save($node);
}
?>
Perfect. Thanks, guys!
Perfect. Thanks, guys!