You are here

function _webform_submit_optionsmarkup in Webform Options Markup 7

Same name and namespace in other branches
  1. 7.2 components/webform_optionsmarkup.inc \_webform_submit_optionsmarkup()

Implements _webform_submit_component().

Convert FAPI 0/1 values into something saveable.

File

components/webform_optionsmarkup.inc, line 321
Webform component that allows markup in checkbox and radio options.

Code

function _webform_submit_optionsmarkup($component, $value) {

  // Build a list of all valid keys expected to be submitted.
  $options = _webform_optionsmarkup_options($component, TRUE);
  $return = NULL;
  if (is_array($value)) {
    $return = array();
    foreach ($value as $option_value) {

      // Handle options that are specified options.
      if ($option_value !== '' && isset($options[$option_value])) {

        // Checkboxes submit an integer value of 0 when unchecked. A checkbox
        // with a value of '0' is valid, so we can't use empty() here.
        if ($option_value === 0 && !$component['extra']['aslist'] && $component['extra']['multiple']) {
          unset($value[$option_value]);
        }
        else {
          $return[] = $option_value;
        }
      }
    }
  }
  elseif (is_string($value)) {
    $return = $value;
  }
  return $return;
}