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(&$form, &$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->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, &$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