函数原型

function drupal_build_form($form_id, &$form_state) {
//---
}

1 填充$form_state

$form_state += form_state_defaults();

2 填充$form_state['input']

  if (!isset($form_state['input'])) {
    $form_state['input'] = $form_state['method'] == 'get' ? $_GET : $_POST;
  }

 3 retrieve form 从函数中取出$form数组

$form = drupal_retrieve_form($form_id, $form_state);

4 prepare form

drupal_prepare_form($form_id, $form, $form_state);

5 process form

drupal_process_form($form_id, $form, $form_state);

6 返回$form变量, 供render函数渲染

return $form;

 ==== prepare form 和 process form 函数的形参是一样的