How can I "merge" two fields when a form is submitted? I have a form from a unique content type which has two fields, when I submit that form, I wish the value entered in the second field was "included" in the end of the first field and then the content type saves.

Like

field1, value: "John"
field2, value: "Doo"


but when the content type is saved, this happens:

field1, value: "John Doo" // the space which divide the two words is required as well.
field2, value: "Doo"


thanks.
I would suggest you hook_node_presave() for this. Write this function somewhere in your custom module, just print the $node array. You would found all the fields value there that you can alter accordingly. Your code should be something like this.

function mymodule_node_presave($node) {
  if ($node-&gt;type == 'content type name') {
   // Append last name field value with first name field.
  }
}


This hook function get executed before node_save() that will save your changes in db.