Drupal's Form API uses an ID field to identify each form. These IDs are usually automatically generated based on the function declaring the form and are therefore, unique. Consequently, they can be used to identify specific forms either while altering the form using hooks such as hook_form_alter()
or for theming purposes using JavaScript and CSS.
In this recipe, we will look at ways to identify the form ID of a form.
We will be using the Devel module to retrieve and display the form ID, and the Search module to simulate a situation where there is more than one form on a page. Additionally, we will be adding our code to the mysite module created earlier in this book. It is assumed that all these modules have been installed and are enabled.
Furthermore, the search block provided by the Search module should be enabled from the block management page for the current theme.