Skip to main content
added the $form_id since that is also part of the path
Source Link

Do like this:

function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'FORM-ID') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'MY_MODULE') . '/js/SCRIPT.js' => array(
        'type' => 'file',
        'group' => JS_LIBRARY, // or JS_DEFAULT, JS_THEME.. read this -  https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_js/7
      ),
    );
  }
}

Do like this:

function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  if ($form['#id'] == 'FORM-ID') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'MY_MODULE') . '/js/SCRIPT.js' => array(
        'type' => 'file',
        'group' => JS_LIBRARY, // or JS_DEFAULT, JS_THEME.. read this -  https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_js/7
      ),
    );
  }
}

Do like this:

function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'FORM-ID') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'MY_MODULE') . '/js/SCRIPT.js' => array(
        'type' => 'file',
        'group' => JS_LIBRARY, // or JS_DEFAULT, JS_THEME.. read this -  https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_js/7
      ),
    );
  }
}
Source Link
xurshid29
  • 2.5k
  • 15
  • 13

Do like this:

function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  if ($form['#id'] == 'FORM-ID') {
    $form['#attached']['js'] = array(
      drupal_get_path('module', 'MY_MODULE') . '/js/SCRIPT.js' => array(
        'type' => 'file',
        'group' => JS_LIBRARY, // or JS_DEFAULT, JS_THEME.. read this -  https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_js/7
      ),
    );
  }
}