Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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"


share|improve this question
up vote 3 down vote accepted

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->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.

share|improve this answer
Thanks a Lot, I'm gonna try it. – bemontibeller Jun 10 '14 at 11:39

Hook_form_alter() would be another option. You can grab the form values in a custom submit handler. Code would look something like this:

function yourmodule_form_alter(&$form,&$form_state,$form_id)
     if($form_id == "your_node_form_id")
          $form['#submit'][] = '_yourmodule_form_custom_submit_handler';

function _yourmodule_form_custom_submit_handler($form,$form_state)
     //here you can grab and alter the $form_state values accordingly
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.