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.


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

naden’s picture

j_ten_man’s picture

Another option:

function 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);
}
Retsage’s picture

Perfect. Thanks, guys!