drupal_build_form 大致是如何运行的呢 ?

函数原型

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 函数的形参是一样的

posted @ 2015-05-11 11:36  qqisnow2021  阅读(239)  评论(0编辑  收藏  举报