Adding js to a drupal node form

Posted by googletorp on Stack Overflow See other posts from Stack Overflow or by googletorp
Published on 2010-04-06T11:28:15Z Indexed on 2010/04/06 11:33 UTC
Read the original article Hit count: 395

Filed under:
|
|
|
|

In Drupal you can create your own nodetype in a custom module. Doing this you get to create your own form which is all very nice.

However if you want to add js the form things get a bit more tricky. If you add the js in the form, the js will only be added form the form when it is loaded. If the user would post the form with validation errors, the form function is not run again and thus the js is not added. Normally you would just create a menu callback and add the js there, but for the node add form, this wont be a possible solution.

So what is the best solution for adding js in a node add form, to keep it persistant when the form doesn't validate?

© Stack Overflow or respective owner

Related posts about drupal

Related posts about drupal-6