You are here

function ctools_context_get_form in Chaos Tool Suite (ctools) 7

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

Return the first context with a form id from a list of contexts.

This function is used to figure out which contexts represents 'the form' from a list of contexts. Only one contexts can actually be 'the form' for a given page, since the @code{<form>} tag can not be embedded within itself.

File

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

Code

function ctools_context_get_form($contexts) {
  if (!empty($contexts)) {
    foreach ($contexts as $id => $context) {

      // If a form shows its id as being a 'required context' that means the
      // the context is external to this display and does not count.
      if (!empty($context->form_id) && substr($id, 0, 15) != 'requiredcontext') {
        return $context;
      }
    }
  }
}