View difference between Paste ID: dZih2FND and Dfn0xAN1
SHOW: | | - or go back to the newest paste.
1
The module 'conditional_field_js' is contained within 'sites/all/modules', and has been enabled within 'admin/modules'.  However, since the module I've created is only supposed to show an alert box upon adding/editing a form, it doesn't work.  The module uses 'drupal_add_js' which calls a js file within the same module folder, and essentially is only supposed to pop an alert box.   Below are my files all contained within the same folder 'sites/all/modules/conditional_field_js':
2
3
4
5
======================
6
conditional_field_js.info
7
======================
8
9
name = Conditional Field JS
10
description = Allows us to fix 'Conditional Fields' module with a javascript file called 'conditional_field_js.js'
11
12
core = 7.x
13
14
15
======================
16
conditional_field_js.module
17
======================
18
19
/****************************************************************************************************/
20
/* Needed for function () function conditional_field_js_after_build($form, &$form_state) {}         */
21
/****************************************************************************************************/
22
 
23
function conditional_field_js_form_alter(&$form, &$form_state, $form_id) {
24
  switch ($form_id) {
25
    case 'my_form':
26-
      $form['#after_build'][] = 'mymodule_after_build';
26+
      $form['#after_build'][] = 'conditional_field_js_after_build';
27
      break;
28
  }
29
}
30
31
/****************************************************************************************************/
32
/* Loads conditional_field_js.js when form is being altered.                                       */
33
/****************************************************************************************************/
34
35
function conditional_field_js_after_build($form, &$form_state) {
36
  $path = drupal_get_path('module', 'conditional_field_js');
37
  drupal_add_js ("$path/conditional_field_js.js");
38
  return $form;
39
40
  
41
}
42
43
44
45
======================
46
conditional_field_js.js
47
======================
48
// Load DOM
49
(function ($) {
50
51
alert('hello');
52
53
}(jQuery));