You are here

function _select2widget_options_properties in Select2 Field Widget 7.2

Same name and namespace in other branches
  1. 7 select2widget.module \_select2widget_options_properties()

Describes the preparation steps required by each widget.

1 call to _select2widget_options_properties()
select2widget_field_widget_form in ./select2widget.module
Implements hook_field_widget_form().

File

./select2widget.reference.inc, line 70

Code

function _select2widget_options_properties($type, $multiple, $required, $has_value) {
  $base = array(
    'filter_xss' => FALSE,
    'strip_tags' => FALSE,
    'empty_option' => FALSE,
    'optgroups' => FALSE,
    'strip_tags_and_unescape' => FALSE,
  );
  $properties = array();
  switch ($type) {
    case 'select2widget':
      $properties = array(
        // Select boxes do not support any HTML tag.
        'strip_tags' => TRUE,
        'strip_tags_and_unescape' => TRUE,
        'optgroups' => TRUE,
      );
      if (!$multiple) {

        // Single select: add a 'none' option for non-required fields,
        // and a 'select a value' option for required fields that do not come
        // with a value selected.
        if (!$required) {
          $properties['empty_option'] = 'option_none';
        }
        elseif (!$has_value) {
          $properties['empty_option'] = 'option_select';
        }
      }
      break;
  }
  return $properties + $base;
}