While it makes sense to prefer the for hook_form_FORM_ID_alter(), it is called
before the more
general hook_form_alter() so if you want to run after all other alterations you
need to use hook_form_alter() .
Also since CCK uses hook_form_alter(), if you want to run after it you need to
use hook_form_alter().
Nevets
On 1/18/2011 8:21 AM, John Fiala wrote:
On Tue, Jan 18, 2011 at 6:16 AM, Leonard den Ottolander.nl
<dru...@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