douju1928 2014-07-28 12:11
浏览 39

如何在hook_theme中呈现输出时删除默认表单标记

I am customizing the login form. I have to put all the three forms(login, register, forgotpassword) into one page. This is my code.

template.php

function bartik_theme() {

    $items = array();

    $items['user_login'] = array(
        'render element' => 'div',
        'arguments' => array('form' => NULL),
        'variables' => array('form' => NULL),
        'path' => drupal_get_path('theme', 'bartik') . '/templates',
        'template' => 'user-login',
        'preprocess functions' => array(
            'bartik_preprocess_user_login'
        ),
   );

    return $items;
}

user-login.tpl.php

<div id="signupbox">

  <?php

    $login_form = drupal_get_form ( 'user_login_block' );
    echo drupal_render ( $login_form );

    $forgot_password_form = drupal_get_form ( 'user_pass' );
    echo drupal_render ( $forgot_password_form );

    $register_form = drupal_get_form ( 'user_register_form' );
    echo drupal_render ( $register_form );

  ?>

</div>

My problem is that all the 3 forms are rendering in one more form tag.

My Output:

<form action="/drupal728/user" method="post" id="user-login">;
    <form>Registration....</form>
    <form>Password....</form>
    <form>Login</form>
</form>

I don't want that unwanted root form tag, how can I remove that one? I am using drupal 7.

  • 写回答

1条回答 默认 最新

  • dongsang6899 2014-07-29 05:59
    关注

    Maybe there is some theme-wrapper? Look in hook_registry_alter() if there is something else.

    Also, Why do you add form in such strange way? If it is login form let it staying login form. Better add additional forms near login form, you can append block or print form in page template.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大