Skip to content

Instantly share code, notes, and snippets.

@ChezFre
Created September 2, 2014 11:20
Show Gist options
  • Save ChezFre/c1d27db85a99b126052e to your computer and use it in GitHub Desktop.
Save ChezFre/c1d27db85a99b126052e to your computer and use it in GitHub Desktop.
Replace node id with other field from referenced node
function Berghoff2014_form_alter(&$form, &$form_state, $form_id) {
if( $form_id === "webform_client_form_33" ) {
/**
** Replace NID from Agent with actual email **
**/
//$node_id = $form['submitted']['agent']['#value'];
$node_id = arg(1);
//$agent = node_load($node_id);
$agent = node_load( $node_id );
$form['submitted']['agent']['#value'] = $agent->field_email['und'][0]['email'];
}
if( $form_id === "webform_client_form_34" ) {
$taxonomy_id = arg(1);
$country = taxonomy_term_load( $taxonomy_id );
$form['submitted']['country']['#value'] = $country->name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment