In drupal_prepare_form() - hook_form_$form-id_alter() execution is separate and prior to hook_drupal_alter() execution, resulting with a module's weight being insignificant in the following scenario:

A module implements hook_form_alter() and module weight = 0;
B module implements hook_form_$form-id_alter() and module weight=30; However it will be executed before A module.

This limits the power of hook_form_$form-id_alter() in tidying the code.

Comments

moshe weitzman’s picture

Status: Active » Closed (works as designed)

The same can be said if we switch these around. Someone always gets to go last - thats the premium position in drupal. This is a timeless problem and we are actually on the verge of solving it since we have hook implementations in the registry now and can add a weight to each one.

moshe weitzman’s picture

Status: Closed (works as designed) » Active

Well, we could swap the order if people want.

amitaibu’s picture

Status: Active » Closed (works as designed)

Also from conversation in IRC with chx and webchick I understand that updating the docs might be good enough - #331832: Document hook_form_FORM_ID_alter().