Skip to content

Instantly share code, notes, and snippets.

@andeersg
Created June 24, 2013 07:51
Show Gist options
  • Save andeersg/5848414 to your computer and use it in GitHub Desktop.
Save andeersg/5848414 to your computer and use it in GitHub Desktop.
Including javascript in form alter
/**
* 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