I created a module, and implemented hook_form_alter() using the following code.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'mymodule_form_id') {
    $form['#validate'] = array('mymodule_form_validate');

Drupal can call the function correctly, and run well for several days.

But one day Drupal did not call the function anymore, until I cleared the cache. Why?

  • 1
    Have you disabled/enabled the module ? – j2r Dec 18 '12 at 10:26
  • Not sure what's going on but I can say you to be cautious because you are removing all existing validation handlers of the module and set it only to mymodule_form_validate. – AyeshK Dec 18 '12 at 14:03

The reason why clearing the caches fixed the issue is because all hooks are cached in Drupal 7 via module_implements(). My guess is something odd happened to your cache and thus your hook went missing from the cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.