Skip to content

Instantly share code, notes, and snippets.

@brett-richardson
Created November 29, 2011 20:01
Show Gist options
  • Save brett-richardson/1406212 to your computer and use it in GitHub Desktop.
Save brett-richardson/1406212 to your computer and use it in GitHub Desktop.
vc_resumes_ajax_submit
function vc_resumes_ajax_submit(){
module_load_include( 'inc', 'vc_resumes', 'vc_resumes.fetch' );
module_load_include( 'inc', 'node', 'node.pages' );
global $user;
// dpm( $_REQUEST );
$form_id = $_REQUEST['form_id'];
$type = explode( '_', $form_id );
$type = $type[0]; /* This will not work with node types with a _ in their name */
if( $form_id == 'resume_node_form' ){
$node = vc_resumes_fetch_or_create_resume();
// dpm( 'Resume edit' );
// dpm( $node );
}
if( $_REQUEST['nid'] ){ /* If updating a node (the resume presumably) */
$node = node_load( $_REQUEST['nid'] );
// dpm( 'Non resume edit' );
// dpm( $node );
} else { /* Creating a new node */
$node =(object) array_merge( array(
'type' => $type,
'uid' => $user->uid,
'status' => 1
), $_REQUEST );
}
node_object_prepare( $node );
// dpm('For submit');
// dpm( $node );
return drupal_get_form( $form_id, $node );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment