码迷,mamicode.com
首页 > 其他好文 > 详细

drupal_retrieve_form 大致是如何运行的?

时间:2015-05-11 14:17:21      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

函数原型是这样的

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

1 把$form_id传到$form_state[‘build_info‘][‘form_id‘]

$form_state[‘build_info‘][‘form_id‘] = $form_id;

2 如果$router_item有include某个文件, 就加载之

 if (!isset($form_state[‘build_info‘][‘files‘][‘menu‘]) && !defined(‘MAINTENANCE_MODE‘)) {
    $item = menu_get_item();
    if (!empty($item[‘include_file‘])) {
      // Do not use form_load_include() here, as the file is already loaded.
      // Anyway, form_get_cache() is able to handle filepaths too.
      $form_state[‘build_info‘][‘files‘][‘menu‘] = $item[‘include_file‘];
    }
  }

3 把$args提出来

$args = $form_state[‘build_info‘][‘args‘];

4 形成一个新的$args

 $args = array_merge(array($form, &$form_state), $args);

我所看到的就是形成了一个新的array
0-0   --- $form
1-form state array  --- $from_state
2-extra array or object   --- $object

5  让form_id这个函数去运行, 并传入$args

  $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);

6 把form_id这个值挂到$form, 然后返回$form

 $form[‘#form_id‘] = $form_id;
 return $form;

 

 



drupal_retrieve_form 大致是如何运行的?

标签:

原文地址:http://www.cnblogs.com/qinqiu/p/4494168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!