2010-04-28 85 views
0

我已經在drupal 6中創建了自定義註冊表單。我已經通過在主題中添加此代碼來改變了drupal註冊頁面的行爲。模板文件如何驗證在drupal中的自定義註冊表單?

function earthen_theme($existing, $type, $theme, $path) { 
    return array(
    // tell Drupal what template to use for the user register form 
    'user_register' => array(
     'arguments' => array('form' => NULL), 
     'template' => 'user_register', // this is the name of the template 
    ), 
); 
} 



和 我user_register.tpl.php文件看起來像這樣...

//php tag starts from here
$forms['access'] = array(
'#type' => 'fieldset',
'#title' => t('Access log settings'),
);
$form['my_text_field']=array('#type' => 'textfield',
'#default_value' => $node->title,
'#size' => 30,
'#maxlength' => 50,
'#required' => TRUE
);

<div id="registration_form"><br> 
    <div class="field"> 
    <?php 
     print drupal_render($form['my_text_field']); // prints the username field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['name']); // prints the username field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['pass']); // print the password field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['account']['email']); // print the password field 
    ?> 
    </div> 
    <div class="field"> 
    <?php 
     print drupal_render($form['submit']); // print the submit button 
    ?> 
    </div> 
</div> 




如何使驗證的 「my_text_field」這是custmized。
準確地說,我希望只要用戶點擊my_text_field,那麼應該打開日期時間選擇器,並且無論用戶選擇哪個日期,該日期都應該是my_text_field中的值。
so guys helps。


由於提前,
尼蒂什
Panchjanya Corporation

回答

2

這是絕對錯誤的。

您應該使用hook_form_alter()來更改表單。它不屬於主題層。

要實現自定義驗證邏輯,請使用#validate callback

+0

是的......我正在嘗試在覈心級別上完成一個日期......我首先嚐試了主題級別,但沒有得到準確的結果....但是,謝謝4重播。 ... – Nitz 2010-05-03 21:24:37

+0

嘿Wim,我已經把另一個問題PLZ檢查出來..現在我做了模塊,但現在我想添加驗證...所以如果你發現任何錯誤,然後PLZ重播我......我的問題是上..... http://stackoverflow.com/questions/2765193/validation-on-user-registration-form – Nitz 2010-05-04 12:28:46