Created
June 24, 2013 07:51
-
-
Save andeersg/5848414 to your computer and use it in GitHub Desktop.
Including javascript in form alter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_form_alter(). | |
*/ | |
function fortytwo_form_alter(&$form, &$form_state, $form_id) { | |
switch ($form_id) { | |
case 'block_admin_display_form': | |
$form['#attached']['js'] = array( | |
drupal_get_path('theme', 'fortytwo') . '/js/mousetrap.js' => array( | |
'scope' => 'footer', | |
), | |
'(function() {Mousetrap.bind("mod+shift+s", function() { document.getElementById("' . $form['#id'] . '").submit(); }); }) ();' => array('type' => 'inline', 'scope' => 'footer'), | |
); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment