函数原型是这样的
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;
时间: 2024-11-29 09:26:25