[development] Weird Javascript behavior after form_set_error on Drupal forms

Scott Reynolds sdrreynolds at gmail.com
Thu Dec 17 18:13:52 UTC 2009


This is because on form error the form comes out of the cache table and
skips fetching the form and all its _alter's. The 'best' practice I have
found is to use a #pre_render function to drupal_add_js(). pre_render's are
called always.
<?php
function my_form_alter() {
  // add my elements
  $form['#pre_render'][] = 'my_load_js';
}
?>

<?php
function my_load_js($form) {
  drupal_add_js();
  return $form;
}
?>

-- 
Scott Reynolds
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091217/87590319/attachment.html 


More information about the development mailing list