function _pardot_form_collapse_form in Pardot Integration 6
Same name and namespace in other branches
- 7 pardot.module \_pardot_form_collapse_form()
Helper function to recurse through posted webform.
Parameters
$tree: The post tree name => value pairs
$posted_values: The post tree, could be name => value pairs or index => value pairs.
$form: The actual form structure of the form.
$result: Return by reference re-structured tree that Pardot will leverage
Return value
none
See also
1 call to _pardot_form_collapse_form()
- _pardot_form_collapse in ./
pardot.module - Collapses a submitted form into a flat array for Pardot.
File
- ./
pardot.module, line 419 - ParDot integration module.
Code
function _pardot_form_collapse_form($tree, $posted_values, $form, &$result) {
foreach ($tree as $name => $value) {
// we need to expand things in fieldsets
if (is_array($value) && !in_array($value, $posted_values)) {
_pardot_form_collapse_form($value, $posted_values, $form[$name], $result);
}
elseif (is_array($value)) {
// If it looks like a date, and the year is reasonable then use slashes
// 0-1-2 = M/D/Y
if (count($value) == 3 && $value[2] > 1900 && $value[2] < 2100 && checkdate($value[0], $value[1], $value[2])) {
$result[$name] = implode('/', $value);
}
else {
$result[$name] = implode(',', $value);
}
}
elseif ($form[$name]['#type'] == 'select') {
// Map select values to text versions. The numeric values won't mean
// much to Pardot, CRM or any other integration.
$result[$name] = $form[$name]['#options'][$value];
}
else {
$result[$name] = $value;
}
}
}