Created
September 18, 2014 20:29
-
-
Save nalipaz/09ae34b323e9ee1c6f43 to your computer and use it in GitHub Desktop.
Drupal: How to correctly add js in a 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
<?php | |
function MODULE_NAME_form_alter($form, &$form_state, $form_id) { | |
... | |
$form['#after_build'] = array('MODULE_NAME_add_assets'); | |
... | |
} | |
function MODULE_NAME_add_assets($element) { | |
drupal_add_js(......); | |
return $element; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment