Hi,

I'm having a difficult time figuring out exactly what happens when a form is submitted to Drupal. For example, on the edit account page, the form attribute action="/?q=user/edit". I assume this leads to a function call that builds a user object from the post parameters and updates the database. Where is this code? How is this explained generally? What combinations of ?q=object/action are there? Is there documentation on this somewhere that I've overlooked? Thanks for any info! The sooner I get a grip on all this the sooner I can start contributing code.

Comments

Steven’s picture

To figure out where a certain page starts, start with a module's _link hook.
The menu()-calls define page urls, which are parsed from bottom to top (i.e. if "user/foo/bar" is requested, then it checks for "user/foo/bar", "user/foo" and "user" before throwing a 404). One of the parameters to menu() is the function which should handle a particular page. Often, multiple pages redirect to the same handler.

In your case:
menu('user/edit', t('edit account'), 'user_page', 0);
So look up user_page().

robertDouglass’s picture

Aha, that helps. Furthermore, I found the code that starts the whole process of reading the GET parameters. It is in common.inc

// initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook:
if (!empty($_GET["q"])) {
  $_GET["q"] = drupal_get_normal_path(trim($_GET["q"], "/"));
}
else {
  $_GET["q"] = drupal_get_normal_path(variable_get("site_frontpage", "node"));
}

// initialize installed modules:
module_init();

But what about the POST parameters? Where do they get marshalled into objects? Centrally? Or is each module individually responsible for that?

- Robert Douglass

-----
visit me at www.robshouse.net

moshe weitzman’s picture

yes, each module reads POST params when it needs to.