Drupal - How do I find a Form_ID for hook_form_FORM_ID_alter?

The form ID is used as the id attribute on the form when it renders.

For content types the pattern is also predictable: node-[TYPE_NAME]-form. So in your case you're looking for: hook_form_node_videos_form_alter().

Another way to handle it is to use the main hook_form_alter() and check the $form_id parameter when you load the form you'd like to target.


You can also just look at the generated markup. the form_id is always present as a hidden form_element, so just search for "form_id" in the source code and you should find it. Make sure you're looking at the correct form wrapper, often there are multiple forms (e.g. search/signup/login blocks)


Enable the development module then in your own .module file to get the form_id

function hook_form_alter(&$form, &$form_state, $form_id) { dpm(form_id);//get the form_id dpm(form);//get the form }

Save the file flush the cache and you can see the form_id.

Tags:

Forms

8