Guest User

Untitled

a guest
Jul 21st, 2012
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ======================
  2. conditional_field_js.info
  3. ======================
  4.  
  5. name = Conditional Field JS
  6. description = Allows us to fix 'Conditional Fields' module with a javascript file called 'conditional_field_js.js'
  7.  
  8. core = 7.x
  9.  
  10.  
  11. ======================
  12. conditional_field_js.module
  13. ======================
  14.  
  15. function conditional_field_js_form_alter(&$form, &$form_state, $form_id) {
  16. switch ($form_id) {
  17. case 'classified_node_form':
  18.  
  19. // (#1) Default behavior
  20. $form['#after_build'][] = 'conditional_field_js_after_build';
  21.  
  22. // (#2) After image field is loaded, all conditional fields display - this corrects the problem
  23. if( $form_state['rebuild'] ) {
  24. drupal_add_js(drupal_get_path('module', 'conditional_field_js') .'/conditional_field_reload.js');
  25. }
  26.  
  27. // (#3) When form validation fails, all conditional fields display - this corrects the problem
  28. $form['#validate'][]='conditional_field_js_form_validate';
  29. }
  30. }
  31.  
  32.  
  33.  
  34. /****************************************************************************************************/
  35. /* Loads required js files. */
  36. /****************************************************************************************************/
  37.  
  38. function conditional_field_js_after_build($form, &$form_state) {
  39. $path = drupal_get_path('module', 'conditional_field_js');
  40. drupal_add_js ("$path/conditional_field.js");
  41.  
  42. return $form;
  43. }
  44.  
  45.  
  46.  
  47. ======================
  48. conditional_field.js
  49. ======================
  50. // Load DOM
  51. (function ($) {
  52.  
  53. alert('hello');
  54.  
  55. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment