You are here

function _hierarchical_select_add_js_settings in Hierarchical Select 6.3

Abstraction around drupal_add_js() and Views' $form_state['js settings'].

Parameters

$settings: The JS settings you'd like to add.

$form_state: A form state array.

2 calls to _hierarchical_select_add_js_settings()
hierarchical_select_process in ./hierarchical_select.module
Hierarchical select form element type #process callback.
_hierarchical_select_setup_js in ./hierarchical_select.module
Helper function to add the required Javascript files and settings.

File

./hierarchical_select.module, line 2327
This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Code

function _hierarchical_select_add_js_settings($settings, &$form_state) {
  global $views_ajax_form_js_settings;

  // If we're on a Views-powered form, we must use $form_state['js settings'].
  if (isset($form_state['view']) && isset($form_state['ajax']) && !empty($form_state['ajax'])) {
    $form_state['js settings'] = !isset($form_state['js settings']) || !is_array($form_state['js settings']) ? array() : $form_state['js settings'];
    $form_state['js settings'] = array_merge_recursive($form_state['js settings'], $settings);
  }
  else {
    drupal_add_js($settings, 'setting');

    // Necessary for Views AJAX pager support.
    // Also see hierarchical_select_ajax_data_alter().
    if (isset($settings['HierarchicalSelect']['settings'])) {
      $views_ajax_form_js_settings = $settings['HierarchicalSelect']['settings'];
    }
  }
}