Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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':
- ======================
- conditional_field_js.info
- ======================
- name = Conditional Field JS
- description = Allows us to fix 'Conditional Fields' module with a javascript file called 'conditional_field_js.js'
- core = 7.x
- ======================
- conditional_field_js.module
- ======================
- /****************************************************************************************************/
- /* Needed for function () function conditional_field_js_after_build($form, &$form_state) {} */
- /****************************************************************************************************/
- function conditional_field_js_form_alter(&$form, &$form_state, $form_id) {
- switch ($form_id) {
- case 'my_form':
- $form['#after_build'][] = 'conditional_field_js_after_build';
- break;
- }
- }
- /****************************************************************************************************/
- /* Loads conditional_field_js.js when form is being altered. */
- /****************************************************************************************************/
- function conditional_field_js_after_build($form, &$form_state) {
- $path = drupal_get_path('module', 'conditional_field_js');
- drupal_add_js ("$path/conditional_field_js.js");
- return $form;
- }
- ======================
- conditional_field_js.js
- ======================
- // Load DOM
- (function ($) {
- alert('hello');
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment