Following is the code snippet I used to generate a the User Profile edit form:

print drupal_render(drupal_get_form('user_profile_form'));

However, I could not find the declaration of the 'user_profile_form' form id anywhere in the Drupal system. So I assumed that it is generated dynamically, but I am not sure.

So, If it is already defined, Where is it defined? and if it is generated dynamically then how does Drupal generates these Form IDs.


1 Answer 1


user_profile_form is defined in user.pages.inc file in user module directory.

The id of the form is the function name which generate the structure of the form in Drupal System. When we call drupal_get_form, it call function name to build the form array.

There is a function drupal_prepare_form in form.inc in includes directory of the Drupal root.

drupal_prepare_form function prepares a structure of the form array and adds required elements, executes any hook_form_alter functions and optionally inserts a validation token to prevent tampering.

Code Snippets to generate form id:

if (!isset($form['#id'])) {
    $form['#id'] = drupal_html_id($form_id);

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.