2012-12-20 49 views
0

在drupal 6中,我製作了一個自定義的user-register.tpl.php表單,當用戶名或電子郵件已存在時,該框變爲紅色,但錯誤信息「您的電子郵件已被註冊「不顯示。當他們成功註冊「您的登錄信息已郵寄給您」時,它們也都不成功。user-register.tpl.php錯誤信息沒有顯示

我該如何解決這個問題? 我的代碼是

<div id="registration_form"> 
    <div class="field"> 
    <?php print drupal_render($form['name']); // prints the username field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
    print drupal_render($form['mail']); // print the email field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
    print drupal_render($form['submit']); // print the submit button 
    ?> 
    </div> 
    <?php 
    print drupal_render($form['timezone']); 
    print drupal_render($form['form_build_id']); 
    print drupal_render($form['form_id']); 
    ?> 
    <?php 
    drupal_set_message('<pre>'. var_export($variables,TRUE) .'</pre>'); 
    ?> 

謝謝

回答

2

您可以在page.tpl.php中打印由drupal_set_message()直接方法制作的消息與變量$消息。因此,在您page.tpl.php中,確保這條線存在:

<?php print $messages; ?> 

現在,如果你需要separataly打印每個錯誤,你必須使用form_get_error($element)其中$元素是名的你的輸入

+0

太棒了!這是有用的,我把這個代碼放在user-register.tpl.php和user-login.tpl.php頁面中,並且沒有顯示出來。把它放在page.tpl.php中。謝謝 –