You are here

function ctools_context_add_required_context_form in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context-admin.inc \ctools_context_add_required_context_form()
1 call to ctools_context_add_required_context_form()
ctools_access_ruleset_ui::edit_form_context in ctools_access_ruleset/plugins/export_ui/ctools_access_ruleset_ui.class.php

File

includes/context-admin.inc, line 200
includes/common-context.inc Provide API for adding contexts for modules that embed displays.

Code

function ctools_context_add_required_context_form($module, &$form, &$form_state, &$form_location, $object, $name = NULL) {
  if (empty($name)) {
    $name = $object->name;
  }
  $form_location = array(
    '#prefix' => '<div id="ctools-requiredcontexts-table">',
    '#suffix' => '</div>',
    '#theme' => 'ctools_context_item_form',
    '#object_name' => $name,
    '#ctools_context_type' => 'requiredcontext',
    '#ctools_context_module' => $module,
  );

  // Store the order the choices are in so javascript can manipulate it.
  $form_location['markup'] = array(
    '#value' => '&nbsp;',
  );
  $choices = array();
  foreach (ctools_get_contexts() as $name => $arg) {
    $choices[$name] = $arg['title'];
  }
  asort($choices);
  if (!empty($choices) || !empty($object->contexts)) {
    ctools_context_add_item_table('requiredcontext', $form_location, $choices, $object->requiredcontexts);
  }
}