You are here

function facetapi_widget_radios in Facet API 6

Builds items as radio for elements.

Parameters

&$build: The facet's render array.

&$key: A string containing the key the facet's render array will be appended to.

&$settings: An array containing the JavaScript settings.

1 string reference to 'facetapi_widget_radios'
facetapi_facetapi_widget_info in ./facetapi.module
Implementation of hook_facetapi_widget_info().

File

./facetapi.widget.inc, line 86
Widget callbacks and building functions.

Code

function facetapi_widget_radios(array &$build, &$key, &$settings) {

  // Gets the default value, on;y one can be passed for radio widget.
  $active_values = $build['#adapter']
    ->getActiveValues($build['#facet']);
  if (!empty($active_values)) {
    $build['#default_value'] = array_shift($active_values);
  }
  else {
    $build['#default_value'] = '__all__';
  }

  // Builds radio element.
  $build['#type'] = 'radios';
  $build['#options'] = array_map('check_plain', facetapi_form_options_get($build, TRUE));
  $build['#prefix'] = '<div class="criterion">';
  $build['#suffix'] = '</div>';
  unset($build[$build['#facet']['field alias']]);
}