You are here

function ctools_dependent_process in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/dependent.inc \ctools_dependent_process()

Process callback to add dependency to form items.

14 string references to 'ctools_dependent_process'
ctools_content_configure_form_defaults in includes/content.inc
Add the default FAPI elements to the content type configuration form
ctools_context_term_settings_form in plugins/contexts/term.inc
ctools_context_user_settings_form in plugins/contexts/user.inc
ctools_custom_content_type_edit_form in plugins/content_types/custom/custom.inc
Returns an edit form for the custom type.
ctools_node_terms_content_type_edit_form in plugins/content_types/node_context/node_terms.inc
Returns an edit form for node terms display settings.

... See full list

File

includes/dependent.inc, line 126
Provide dependent checkboxes that can be easily used in forms.

Code

function ctools_dependent_process($element, $edit, &$form_state, &$form) {
  if (isset($element['#dependency'])) {
    if (!isset($element['#dependency_count'])) {
      $element['#dependency_count'] = 1;
    }
    if (!isset($element['#dependency_type'])) {
      $element['#dependency_type'] = 'hide';
    }
    $js = array(
      'values' => $element['#dependency'],
      'num' => $element['#dependency_count'],
      'type' => $element['#dependency_type'],
    );
    if (!empty($form_state['ajax'])) {
      $form_state['js settings']['CTools']['dependent'][$element['#id']] = $js;
    }
    else {
      ctools_add_js('dependent');
      $options['CTools']['dependent'][$element['#id']] = $js;
      drupal_add_js($options, 'setting');
    }
  }
  return $element;
}