Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ======================
- 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
- ======================
- function conditional_field_js_form_alter(&$form, &$form_state, $form_id) {
- switch ($form_id) {
- case 'classified_node_form':
- // (#1) Default behavior
- $form['#after_build'][] = 'conditional_field_js_after_build';
- // (#2) After image field is loaded, all conditional fields display - this corrects the problem
- if( $form_state['rebuild'] ) {
- drupal_add_js(drupal_get_path('module', 'conditional_field_js') .'/conditional_field_reload.js');
- }
- // (#3) When form validation fails, all conditional fields display - this corrects the problem
- $form['#validate'][]='conditional_field_js_form_validate';
- }
- }
- /****************************************************************************************************/
- /* Loads required js files. */
- /****************************************************************************************************/
- function conditional_field_js_after_build($form, &$form_state) {
- $path = drupal_get_path('module', 'conditional_field_js');
- drupal_add_js ("$path/conditional_field.js");
- return $form;
- }
- ======================
- conditional_field.js
- ======================
- // Load DOM
- (function ($) {
- alert('hello');
- }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment