[development] Overriding function declared in another module

John Fiala jcfiala at gmail.com
Tue Jan 18 14:21:17 UTC 2011


On Tue, Jan 18, 2011 at 6:16 AM, Leonard den Ottolander.nl
<drupal at den.ottolander.nl> wrote:
> Hello Jamie,
>
> On Tue, 2011-01-18 at 07:29 -0500, Jamie Holly wrote:
>> The trick is to set the
>> weight of your module higher than the weight of the menu module so that
>> the hook runs after menu's hook_form_alter.
>
> Right. That did the trick. Thanks!
>
> The fact that I saw no explicit hooking confused me. I assume every
> module hooks to the forms using <module name>_form_alter implicitly?

Exactly.  Knowing how to use the hook_form_alter hooks properly makes
customizing Drupal much easier.

Each time a form is built, it gets sent through every hook_form_alter
implementation in every active Drupal Module.  And, as FGM pointed it,
it also goes through a specific hook: hook_form_FORM_ID_alter.  Have a
look at both of these and play around with them.  I personally prefer
to use the second one, because it's more specific and obvious what it
does, and you don't get one of those huge if/switch statements in the
hook... but sometimes you need to use hook_form_alter because your
changes apply across a couple of related forms, especially the node
forms.



-- 
John Fiala
www.jcfiala.net


More information about the development mailing list