1 options.module _options_prepare_options(&$options, $properties)

Sanitizes the options.

The function is recursive to support optgroups.

File

core/modules/field/modules/options/options.module, line 279
Defines selection, check box and radio button widgets for text and numeric fields.

Code

function _options_prepare_options(&$options, $properties) {
  foreach ($options as $value => $label) {
    // Recurse for optgroups.
    if (is_array($label)) {
      _options_prepare_options($options[$value], $properties);
    }
    else {
      // The 'strip_tags' option is deprecated. Use 'strip_tags_and_unescape'
      // when plain text is required (and where the output will be run through
      // check_plain() before being inserted back into HTML) or 'filter_xss'
      // when HTML is required.
      if ($properties['strip_tags']) {
        $options[$value] = strip_tags($label);
      }
      if (!empty($properties['strip_tags_and_unescape'])) {
        $options[$value] = decode_entities(strip_tags($label));
      }
      if ($properties['filter_xss']) {
        $options[$value] = field_filter_xss($label);
      }
    }
  }
}