You are here

function conditional_fields_add_js in Conditional Fields 6.2

Same name and namespace in other branches
  1. 5 conditional_fields.module \conditional_fields_add_js()
  2. 6 conditional_fields.module \conditional_fields_add_js()

Adds javascript to the node editing form.

This function ensures that the settings are added only once for each form on the page that includes conditional fields.

Parameters

$settings: An array of settings keyed by the form's #build_id property.

2 calls to conditional_fields_add_js()
conditional_fields_node_after_build in ./conditional_fields.module
Main tasks:
conditional_fields_node_form_validate in ./conditional_fields.module
Validation for node editing form.

File

./conditional_fields.module, line 1174
Content fields and groups visibility based on the values of user defined 'trigger' fields.

Code

function conditional_fields_add_js($settings) {
  static $js;
  $build_id = current(array_keys($settings));
  if (!isset($js[$build_id])) {
    drupal_add_js(array(
      'ConditionalFields' => $settings,
    ), 'setting');
    drupal_add_js(drupal_get_path('module', 'conditional_fields') . '/conditional_fields.js');
    $js[$build_id] = TRUE;
  }
}