function ctools_context_selector in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/context.inc \ctools_context_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.
3 calls to ctools_context_selector()
- ctools_access_ajax_edit_item in includes/
context-access-admin.inc - Form to edit the settings of an access test.
- ctools_content_configure_form_defaults in includes/
content.inc - Add the default FAPI elements to the content type configuration form
- ctools_edit_relationship_form in includes/
context-admin.inc - Form (for ajax use) to add a relationship
File
- includes/
context.inc, line 282 - Contains code related to the ctools system of 'context'.
Code
function ctools_context_selector($contexts, $required, $default) {
if (is_array($required)) {
$result = array(
'#tree' => TRUE,
);
$count = 1;
foreach ($required as $id => $r) {
$result[] = _ctools_context_selector($contexts, $r, isset($default[$id]) ? $default[$id] : '', $count++);
}
return $result;
}
return _ctools_context_selector($contexts, $required, $default);
}