With hook_form_$form-id_alter() module's weight might be insignificant

Amitaibu - November 6, 2008 - 09:13
Project:Drupal
Version:7.x-dev
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

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.

#1

moshe weitzman - November 9, 2008 - 12:42
Status:active» by design

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.

#2

moshe weitzman - November 9, 2008 - 12:52
Status:by design» active

Well, we could swap the order if people want.

#3

Amitaibu - November 9, 2008 - 12:58
Status:active» by design

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().

 
 

Drupal is a registered trademark of Dries Buytaert.