Whenever a required field is left out (such as the Title field), neither the .js file or the .css file is loaded. I'm not terribly experienced with hook_form_alter... I don't think this function runs during a validation error... maybe the files should be attached using a different hook?
Any ideas?
Comments
Comment #1
jessehsI found a workaround here by adding a validation function. See http://drupal.org/node/322290 for a discussion on this topic. I'm hacking the module here and adding a validation function. Just paste these two functions in place of the current taxonomy_tree_select_form_alter() function.
I realize this is a bit redundant. I'd like to know if there's a more concise way of doing this...
Comment #2
danillonunes commentedjessehs, thanks for the report.
I fix it by using an #after_build function that is also loaded with an validation error page.
Just wait for the next release :-)
Comment #4
cableman0408 commentedI used the #after_build method to add js/css and it worked perfect (thanks). Just remember to return the form from the after build function.
Comment #5
pshahmumbai commentedI readded the same javascript code to the form validation function itself.
function someform_form_validate($form, &$form_state)
{
.....
drupal_add_js($some_js_code, 'inline', 'header');
}
Comment #6
jphelan commentedUsing form attach also solves this.
Comment #7
danillonunes commentedjphelan, this method works for Drupal 7 only, this module is for Drupal 6.
Also this issue was already fixed by the commit: http://drupalcode.org/project/taxonomy_tree_select.git/commit/780ba62. If you’re are still facing the bug with the latest version of the module, feel free to reopen this issue. :)
Comment #8
merlin06 commentedDon't use the code in #6 as it will replace all other js attached to $form.
You want to use something like this instead:
$form['#attached']['js'][] = drupal_get_path('module', 'ajax_example') . '/ajax_example.js';Comment #9
graham leach commentedDrupal 7 Ubercart 3 site.
hook_init() - NOPE
hook_form_alter() - NOPE
This worked: