From Programming in Drupal Way
Display the Form
drupal_get_form($form_id)
Form Callbacks
There has 3 callbacks: form callback, validate callback, submit callback.
xxx_form($form_state)
xxx_form_validate($form, &$form_state)
xxx_form_submit($form, &$form_state)
Form theme: theme_xxx_form($form)
Functions can be used in form theme:
drupal_render(&$elements)
Example:
$output .= drupal_render($form['name']);
……
$output .= drupal_render($form);
Hooks
hook_forms()
This hook is for map form_ids to builder functions.
hook_form_alter(&$form, $form_state, $form_id)
This hook allow any form (even those in core) can be altered in almost any way imaginable–elements can be removed, added, and rearranged