2014. augusztus 1., péntek

Alter order of hook_form_FORM_ID_alter?


Using hook_module_implements_alter or by increasing the weight of a module, you can change the order of hook_form_alter implementations. E.G:



function custom_module_implements_alter(&$implementations, $hook) { if ($hook == 'form_alter') { $module = 'custom'; unset($implementations[$module]); $implementations[$module] = NULL; } }

How can I change the order of the form specific hooks for a specific form id? I was expecting something like this to work, but it doesn't:



function custom_form_user_register_form_alter(&$form, &$form_state) {} function custom_module_implements_alter(&$implementations, $hook) { if ($hook == 'form_user_register_form_alter') { $module = 'custom'; unset($implementations[$module]); $implementations[$module] = NULL; } }

It does successfully enter the conditional, and replace the order, but then inside drupal_alter, it merges the order of the form_alter hooks, with the order of the specific form_FORM_ID_alter hooks, and the former takes priority.


So is this a bug? Am I doing something wrong, or does Drupal not support ordering specific form alter hooks?






Nincsenek megjegyzések:

Megjegyzés küldése