Drupal 6. What is the proper way to execute drupal_add_js only when specific content_type is being created?
I have some jQuery code that needs to execute only to control some form elements in a specific content_type creation.
I already have a module, which has a different name from the content_type. Is this a problem? Can I still hook onto the form? If so, what is the correct way to generate the hook to the specific node/add/content_type?
Edit: this is only needed for the creation, not the view.
Edit 2: code that’s not working at the moment:
file: testmod.module
function testmod_form_node_type_form_alter(&$form, &$form_state) {
if ($form['#node_type']->type == 'testnode') {
drupal_add_js(drupal_get_path('module', 'testmod') . '/new_msg.js');
}
}
There are probably a few ways to do it but I’d use a
form_alterhook: