You are here

function facetapi_form_options_get in Facet API 6

Builds array of options, pulls values from the facet's "values callback" function or builds from the facet's items of the callback is not set.

NOTE: The option values are return unescaped. It is the responsibility of the widget to escape the values.

Parameters

$build: The facet's render array.

$all_option: A boolean flagging whether to append an "include all" option.

Return value

An array containing the FAPI options.

4 calls to facetapi_form_options_get()
facetapi_widget_checkboxes in ./facetapi.widget.inc
Builds items as checkbox form elemets.
facetapi_widget_multiselect in ./facetapi.widget.inc
Builds items as a multiple value select list element.
facetapi_widget_radios in ./facetapi.widget.inc
Builds items as radio for elements.
facetapi_widget_select in ./facetapi.widget.inc
Builds items as a select list element.

File

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

Code

function facetapi_form_options_get(&$build, $all_option = FALSE) {
  $field_alias = $build['#facet']['field alias'];

  // Initializes options.
  if (!$all_option) {
    $options = array();
  }
  else {

    // @todo The text should be a setting.
    $options = array(
      '__all__' => t('<All>'),
    );
  }

  // Builds options.
  if (!empty($build['#facet']['values callback']) && function_exists($build['#facet']['values callback'])) {
    $options += $build['#facet']['values callback']($build['#facet']);
  }
  else {
    foreach ($build[$field_alias] as $value => $item) {
      $options[$value] = $item['#value'];
    }
  }
  return $options;
}