function views_process_dependency

2.x form.inc views_process_dependency($element, $edit, &$form_state, &$form)

Process callback to add dependency to form items.

Usage:

On any form item, add

'#process' => 'views_process_dependency' 
'#dependency' => array('id-of-form-without-the-#' => array(list, of, values, that, make, this, gadget, visible)); 
27 string references to 'views_process_dependency'
views_handler_argument::default_argument_form in handlers/views_handler_argument.inc
Provide a form for selecting the default argument when the default action is set to provide default argument.
views_handler_argument_string::options_form in handlers/views_handler_argument_string.inc
Provide a form for setting options.
views_handler_argument_term_node_tid_depth::options_form in modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
Provide a form for setting options.
views_handler_field::options_form in handlers/views_handler_field.inc
Default options form that provides the label widget that all fields should have.
views_handler_field_date::options_form in handlers/views_handler_field_date.inc
Default options form that provides the label widget that all fields should have.

... See full list

File

includes/form.inc, line 265
form.inc Views' replacements for Drupal's form functions.

Code

function views_process_dependency($element, $edit, &$form_state, &$form) {
  static $dependencies;
  if (isset($element['#dependency']) && !isset($dependencies[$element['#id']])) {
    if (!isset($element['#dependency_count'])) {
      $element['#dependency_count'] = 1;
    }
    if (!empty($form_state['ajax'])) {
      $form_state['js settings']['viewsAjax']['formRelationships'][$element['#id']] = array('num' => $element['#dependency_count'], 'values' => $element['#dependency']);
    }
    else {
      views_add_js('dependent');
      $options['viewsAjax']['formRelationships'][$element['#id']] = array('num' => $element['#dependency_count'], 'values' => $element['#dependency']);
      drupal_add_js($options, 'setting');
    }
    $dependencies[$element['#id']] = TRUE;
  }

  return $element;
}