0

我在 drupal 6 中创建了自定义注册表单。我通过在主题中添加此代码来更改了 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”进行验证。
正是我希望用户单击 my_text_field 时,日期时间选择器应该打开,并且无论用户选择哪个日期,该日期都应该是 my_text_field 中的值。
所以大家帮忙。


在此先感谢
nitish
Panchjanya Corporation

4

2 回答 2

2

那是绝对错误的。

您应该使用hook_form_alter()来更改表单。它不属于主题层。

要实现自定义验证逻辑,请使用#validate 回调

于 2010-05-01T17:58:45.067 回答
0

真的吗?

有 Drupal 专家说您可以在主题中自定义表单。见http://www.lullabot.com/articles/modifying-forms-drupal-5-and-6

于 2011-01-13T03:38:19.203 回答