0

I would like to know if it's possible to populate a node fields with the values from form_state or something like that.

Basically what I do is to show a register form merged with a form from a Content Type. I do that by using field_attach_form(). Now on submit I create a node using:

$node = new stdClass(); $node->type = 'company'; $node->uid = 1; node_object_prepare($node);

and now I would like to get all values from form_state and put them into the node.

Many thanks!

mihai
  • 43
  • 8

1 Answers1

0

Hook your form, add new submit handler and place your code there.

MilanG
  • 6,994
  • 2
  • 35
  • 64
  • And the values to insert in the node? How do I put them there? – mihai Jul 08 '15 at 13:26
  • Thanks for answering, but I don't think you understand my question. I know how to create a node pragmatically; the problem I have is that I need to put the values from the $form and $form_state in the node. Without doing something like: $node->title = $form['bla bla]; I would guess something like creating an object from $form and then do node_save($that_object); – mihai Jul 10 '15 at 08:23
  • Also, I've tried something like node_form_submit_build_node($form, $form_state);but with no results. It just gives me a blank page. – mihai Jul 10 '15 at 08:25
  • A-ha,...sorry then. I manually read and store values as you explained. Don't know for any other way. – MilanG Jul 10 '15 at 11:29