2

I was looking at the login form tag of Drupal and was surprised that it does not reference any specific page to handle login. Example:

<form action="/node?destination=node" .....>

Or if I go to the login page directly:

<form action="/user/login" .....>

or

<form action="/user" .....>

So how does this work? How does the browser know which page to submit the POST data to?

1 Answer 1

1

Drupal uses the Form API to handle this. It doesn't need a specific page to handle the POST data because of the way its structured. Also see user_login to get an idea of how it's implemented. You can see that it sets specific validation functions to be called when the form is submitted, and then it moves on to user_login_submit (this part happens due to the default naming conventions of the Form API). There's other magic in there that makes this all work, but it usually isn't necessary to understand it in order to develop with Drupal.

2
  • Thanks. Sorry I can't up you yet. I would however love to know the magic as well. Thanks! Commented Nov 10, 2011 at 7:46
  • Then check out the relevant topic on api.drupal.org :) Commented Nov 10, 2011 at 7:48

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.