Apply a dynamic string to a field before validation I am attempting to set the "title" value of a content type before it becomes "required" . So what happens is the title field becomes hidden based on user name, after filling in the "first name" and "last name" fields I need to take those values and then apply them to the "title" field, before drupal states that the field is required. Here's what I have so far

/**
*  Implements hook_form_alter().
*/

function editorhide_form_alter(&amp;$form, &amp;$form_state, $form_id){
//form id = artist_node_form
//title id = edit-title label: edit-title   

global $user;
global $fullTitle;

if($form_id == 'artist_node_form'){     
    hide($form['artist_node_form']['edit-title']);
   if( $user-&gt;name == 'Editor'){        

        // drupal_add_js("jQuery(document).ready(function(){
        //  jQuery('#edit-title').hide();
        // });","inline");              
        $form['#submit'][] = "editorhide_form_submit_handler";





     }
}

}

//submit form handler.

function editorhide_form_submit_handler ($form, &amp;$form_state) {

  $fullTitle = array();
  $fullTitle['0'] = $form_state['values']['field_firstname']['und']['0']['value'];
  $fullTitle['0'] .= ' '. $form_state['values']['field_lastname']['und']['0']['value'];
  form_set_value( $form_state['title'], $fullTitle['0'],$form_state);

}


With the current code it throws a error:: Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be an array, null given, called in
First You should write the these kind logic in validate function rather than the submit function. 

So instead of

$form['#submit'][] = "editorhide_form_submit_handler"; 

you should have 

$form['#validate'][] = "editorhide_form_submit_handler";

Second the first parameter passed to the function form_set_value is the form element and not the form state value so the function should look like.

form_set_value( $form['title'], $fullTitle['0'],$form_state);


I think what you are trying to achieve can be done with a custom module. 

Automatic Nodetitles


  "auto_nodetitle" is a small and efficient module that allows hiding of
  the content title field in the form. To prevent empty content title
  fields one can configure it to generate the title by a given pattern.
  
  When the token module is installed it's possible to use various node
  data for the auto generated title - e.g. use the text of a CCK field
  (since 5.x).