You are here

function panels_common_add_required_context_form in Panels 5.2

Same name and namespace in other branches
  1. 6.2 includes/common-context.inc \panels_common_add_required_context_form()
1 call to panels_common_add_required_context_form()
panels_mini_context_form in panels_mini/panels_mini.module
Form to edit the context settings of a mini panel.

File

includes/common.inc, line 596
Functions used by more than one panels client module.

Code

function panels_common_add_required_context_form($module, &$form, &$form_location, $object) {
  $form['requiredcontexts'] = array(
    '#type' => 'value',
    '#value' => $object->requiredcontexts,
  );
  $form_location = array(
    '#prefix' => '<div id="panels-requiredcontexts-table">',
    '#suffix' => '</div>',
    '#theme' => 'panels_common_context_item_form',
    '#panel_name' => $object->name,
    '#panels_context_type' => 'requiredcontext',
    '#panels_context_module' => $module,
  );

  // Store the order the choices are in so javascript can manipulate it.
  $form_location['markup'] = array(
    '#value' => '&nbsp;',
  );
  $form['requiredcontext_order'] = array(
    '#type' => 'hidden',
    '#id' => 'requiredcontext-order',
    '#default_value' => $object->requiredcontexts ? implode(',', array_keys($object->requiredcontexts)) : '',
  );
  $choices = array();
  foreach (panels_get_contexts() as $name => $arg) {
    $choices[$name] = $arg['title'];
  }
  asort($choices);
  if (!empty($choices) || !empty($object->contexts)) {
    panels_common_add_item_table('requiredcontext', $form_location, $choices, $object->requiredcontexts);
  }
  return _panels_common_context_js($object->name, $module, 'requiredcontext');
}