[development] Overriding function declared in another module

Justin Ellison justin at techadvise.com
Tue Jan 18 15:37:11 UTC 2011

Code speaks truth, you're correct.  However, there's some
contradicting documentation.

>From http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_form_alter/7:
"For each module (in system weight order) the general form alter hook
implementation is invoked first, then the form ID specific alter
implementation is called."

>From http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_form_FORM_ID_alter/6:
"Note that this hook fires before hook_form_alter(). Therefore all
implementations of hook_form_FORM_ID_alter() will run before all
implementations of hook_form_alter(), regardless of the module order."

Unfortunately, Google returns the former link first, which must've
been what I learned from.

Sorry for any confusion,


On Tue, Jan 18, 2011 at 9:26 AM, Steve Ringwood <nevets at tds.net> wrote:
> Justin
>    Not sure what you are referring to in the docs for hook_form_alter but
> here is the relavent code
>    from form.inc, function drupal_prepare_form().
>  $data = &$form;
>  $data['__drupal_alter_by_ref'] = array(&$form_state);
>  drupal_alter('form_'. $form_id, $data); << Form ID specific call
>  // __drupal_alter_by_ref is unset in the drupal_alter() function, we need
>  // to repopulate it to ensure both calls get the data.
>  $data['__drupal_alter_by_ref'] = array(&$form_state);
>  drupal_alter('form', $data, $form_id); << General call (hook_form_alter)
> Nevets

More information about the development mailing list