How hook_form_alter works in drupal7 ?

Satyam Updhyay - - Drupal, Drupal Beginners

Working strategy of hook_form_alter

This hook perform the alterations before the form is submitted or rendered. This hook hook_form_alter($form, $form_state, $form_id), this hook has 3 parameters

1) $form: Nested array of form elements that comprise the form.
2) $form_state: A keyed array containing the current state of the form. The arguments that drupal_get_form() was originally called with are available in the array $form_state[‘build_info’][‘args’].
3) $form_id: This id should be match to the id of that form, that have to randred by this module.

Now you can create module using this hook to learn it more:
If you are familiar to module development in drupal7, then you can get it easily. First of all you have to create the info file for your module like

name = My Form Alter
description = This is the module using form alter to make changes for the exsiting form
package = custom
core = 7.x

and then you have to create the module file for that


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.