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 に答える