You are here

function ctools_context_converter_selector in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \ctools_context_converter_selector()

Create a select box to choose possible contexts.

This only creates a selector if there is actually a choice; if there is only one possible context, that one is silently assigned.

If an array of required contexts is provided, one selector will be provided for each context.

Parameters

$contexts: A keyed array of all available contexts.

$required: The required context object or array of objects.

Return value

A form element, or NULL if there are no contexts that satisfy the requirements.

1 call to ctools_context_converter_selector()
views_content_views_content_type_edit_form in views_content/plugins/content_types/views.inc
Returns an edit form for a block.

File

includes/context.inc, line 375
Contains code related to the ctools system of 'context'.

Code

function ctools_context_converter_selector($contexts, $required, $default) {
  if (is_array($required)) {
    $result = array(
      '#tree' => TRUE,
    );
    $count = 1;
    foreach ($required as $id => $r) {
      $result[] = _ctools_context_converter_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
    }
    return $result;
  }
  return _ctools_context_converter_selector($contexts, $required, $default);
}