You are here

function _webform_submit_select in Webform 5

Same name and namespace in other branches
  1. 5.2 components/select.inc \_webform_submit_select()
  2. 6.3 components/select.inc \_webform_submit_select()
  3. 6.2 components/select.inc \_webform_submit_select()
  4. 7.4 components/select.inc \_webform_submit_select()
  5. 7.3 components/select.inc \_webform_submit_select()

Translates the submitted 'safe' form values back into their un-edited original form.

Parameters

$data: The POST data associated with the component.

$component: An array of information describing the component, directly correlating to the webform_component database schema.

Return value

Nothing.

File

components/select.inc, line 216

Code

function _webform_submit_select(&$data, $component) {
  $value = _webform_filtervalues($component['value'], FALSE);
  $rows = explode("\n", _webform_filtervalues($component['extra']['items'], FALSE));
  foreach ($rows as $row) {
    $row = trim($row);
    if (preg_match('/^([^"|]+)\\|(.*)$/', $row, $matches)) {
      $options[$matches[1]] = $matches[1];
    }
    else {
      $options[_webform_safe_name($row)] = $row;
    }
  }
  if (is_array($data)) {
    foreach ($data as $key => $value) {
      if ($value) {
        $data[$key] = $options[$key];
      }
      else {
        $data[$key] = NULL;
      }
    }
  }
  elseif (!empty($data)) {
    $data = $options[$data];
  }
}