You are here

function ctools_context_add_argument_form in Chaos Tool Suite (ctools) 7

Same name and namespace in other branches
  1. 6 includes/context-admin.inc \ctools_context_add_argument_form()

Add the argument table plus gadget plus javascript to the form.

File

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

Code

function ctools_context_add_argument_form($module, &$form, &$form_state, &$form_location, $object, $cache_key = NULL) {
  if (empty($cache_key)) {
    $cache_key = $object->name;
  }
  $form_location = array(
    '#prefix' => '<div id="ctools-arguments-table">',
    '#suffix' => '</div>',
    '#theme' => 'ctools_context_item_form',
    '#cache_key' => $cache_key,
    '#ctools_context_type' => 'argument',
    '#ctools_context_module' => $module,
  );
  $args = ctools_get_arguments();
  $choices = array();
  foreach ($args as $name => $arg) {
    if (empty($arg['no ui'])) {
      $choices[$name] = $arg['title'];
    }
  }
  asort($choices);
  if (!empty($choices) || !empty($object->arguments)) {
    ctools_context_add_item_table('argument', $form_location, $choices, $object->arguments);
  }
}