You are here

function _eloqua_form_url_map in Eloqua 6

Same name and namespace in other branches
  1. 7.2 eloqua_webform/eloqua_webform.module \_eloqua_form_url_map()
  2. 7 eloqua_webform/eloqua_webform.module \_eloqua_form_url_map()

Maps the url parameters to the associated form fields

Parameters

$form:

$component_list: The components must be keyed by cid

Return value

void

1 call to _eloqua_form_url_map()
eloqua_form_alter in ./eloqua.module
Implementation of hook_form_alter().

File

./eloqua.module, line 458

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 = _eloqua_form_url_get_component_path($component_list, $component);
    $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);
  }
}