function _eloqua_form_url_map in Eloqua 7.2
Same name and namespace in other branches
- 6 eloqua.module \_eloqua_form_url_map()
- 7 eloqua_webform/eloqua_webform.module \_eloqua_form_url_map()
Maps the URL parameters to the associated form fields.
Parameters
array $form: The form.
array $component_list: The components must be keyed by CID.
1 call to _eloqua_form_url_map()
- eloqua_webform_form_alter in eloqua_webform/
eloqua_webform.module - Implements hook_form_alter().
File
- eloqua_webform/
eloqua_webform.module, line 387
Code
function _eloqua_form_url_map(&$form, $component_list) {
foreach ($component_list as $component) {
if (empty($component['extra']['eloqua']['query_name'])) {
continue;
}
// Check whether the value is indeed in the query.
$field_param_name = $component['extra']['eloqua']['query_name'];
if (!array_key_exists($field_param_name, $_REQUEST)) {
continue;
}
// Determine nesting level.
$path = array(
$component['form_key'],
);
$current_component = $component;
// Walk up the path.
while ($current_component != NULL && $current_component['pid'] != 0) {
$current_component = $component_list[$current_component['pid']];
array_unshift($path, $current_component['form_key']);
}
$target_element =& $form['submitted'];
$pass = TRUE;
foreach ($path as $level) {
if (array_key_exists($level, $target_element)) {
$target_element =& $target_element[$level];
}
else {
$pass = FALSE;
continue;
}
}
// If we found the target form element, update the default value.
if ($pass) {
$conversion_method = '_eloqua_form_url_map_' . $component['type'];
if (function_exists($conversion_method)) {
$conversion_method($_REQUEST[$field_param_name], $target_element);
}
else {
$target_element['#default_value'] = $_REQUEST[$field_param_name];
}
}
// Release the reference.
unset($target_element);
}
}