I want to create an associative array of submitted form data and do some additional processing on the submitted data (namely send the data over http POST). I have the following code:
function webformssalesforce_form_alter(&$form, &$form_state, $form_id) {
if (substr($form_id, 0, 20) == 'webform_client_form_') {
// Add the submit handler after the existing Webform submit handler,
// but before the second Webform handler. Pop off the first one and add
// ours second.
$first = array_shift($form['#submit']);
array_unshift($form['#submit'], $first, 'webformssalesforce_client_submit');
}
}
function webformssalesforce_client_submit($form, &$form_state) {
$node = node_load($form_state['values']['details']['nid']);
$fields = Array();
foreach($form_state["values"]["submitted_tree"] as $key=>$value) {
if(! is_array ( $value)){
$fields[$key] = $value;
}
}
//do stuff with $fields
}
This works fine for text and email fields, however for select elements I get the option's safe_value instead of the display value for the select. So for example if an element has the folowing options:
1|Display value 1
2|Display value 2
3|Display value 3
How can I get the display value instead of the safe_value (Display value 2 instead of 2) for an element?
I'm pretty sure this code worked fine for me with a previous version of webform.