You are here

function _webform_submit_grid in Webform 5

Same name and namespace in other branches
  1. 5.2 components/grid.inc \_webform_submit_grid()
  2. 6.2 components/grid.inc \_webform_submit_grid()

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/grid.inc, line 159

Code

function _webform_submit_grid(&$data, $component) {
  $value = _webform_filtervalues($component['value']);
  $rows = explode("\n", _webform_filtervalues($component['extra']['options']));
  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[$value];
      }
    }
  }
  elseif (!empty($data)) {
    $data = $options[$data];
  }
}