2011-07-04 39 views
0

我试图将user_profile_form插入页面。代码相当简单:Drupal 7,将user_profile_form插入页面

global $ user; module_load_include('inc','user','user.pages'); print drupal_render(drupal_get_form('user_profile_form',$ user,'account'));

一切正常除了当载图像,它显示了:

“警告:call_user_func_array()[function.call-用户FUNC阵列]:第一个参数是有望成为一种有效的回调, 'user_profile_form'在drupal_retrieve_form给予()”

任何想法,THX很多

回答

3

你需要使用form_load_include(),而不是module_load_include的加载/共建的形式,你必须通过$ form_state内部参数。

您正在寻找看起来像代码:

$form_id = 'user_profile_form'; 
    $form_state = array(); 
    //passing arguments to form. 
    $form_state['build_info']['args'] = array($account, 'account'); 

    form_load_include($form_state, 'inc', 'user', 'user.pages'); 

    $form = drupal_build_form($form_id, $form_state); 
+0

要构建$ account变量,请使用以下代码 global $ user; $ account = user_build_content($ user); –

+0

这是行不通的,但我得到:注意:试图获取user_account_form()中的非对象的属性(/var/www/modules/user/user.module的第1019行) –

0

为了防止通知或警告:

试图让非对象的财产user_account_form()(1019线/无功/网络/模块/用户/ user.module)

变化的最后两行:

<?php 
    $output_form = drupal_get_form($form_id); 
    print render($output_form); 
?>