Since the page alter hook also has information about individual form fields is it correct to say that hook page alter can do everything that hook form alter can do

2 Answers 2


Not, for sure hook_page_alter can't do everything that hook_form_alter (or other form alter hooks) can do.

Form alter functions allow to alter the form itself, its structure, values and valid values, submit and validate handlers, etc. This is because they are fired early in the Form API workflow. When Form API ends its work there's a render array that Drupal can render as HTML code.

After all form alter hooks are done (and any other code that generates the page content) comes hook_page_alter, but the form is done. Any alterations you make will be unkown for the Form API layer, most of the times resulting in strange validation errors form Form API (for example the 'Illegal Choice has been detected').

What you see in the hook_page_alter is not a form but the render array of a form: Here you can't modify submit or validate handlers, options of a select wiidget or add new elements in a multiple element field.

From hook_page_alter:

If you are making changes to entities such as forms, menus, or user profiles, use those objects' native alter hooks instead (hook_form_alter(), for example).


in my opinion hook_page_alter() is a different thing from hook_form_alter() in the page_alter your alter some result view before it gets rendered but in form_alter you alter the values that gives you that result in database ,, page_alter you just alter the page view far from the database ,,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.