我是drupal新手。Drupal 7定製用戶註冊表
我需要通過添加例如像id字段自定義登記表,手機等
我可以通過創建一個自定義模塊做到這一點?
如果是的話,請幫助我一個關於創建和覆蓋默認用戶註冊提交功能的簡單想法。我必須將這些細節插入到另一個表中,並且還必須將這些數據作爲服務請求傳遞。
香港專業教育學院創建自定義模塊功能
module_form_alter(&$form,&$form_state,$form_id){
$form['#submit'] = 'module_form_submit';
if($form_id == 'user_register_form'){
//print_r($form_id);
$form['email'] = array(
'#type' => 'textfield',
'#title' => t('id'),
'#default_value' => '',
'#size' => 60,
'#maxlength' => 15,
'#required' => TRUE,
);
}
}
function module_form_submit($form, &$form_state){
echo "test";
exit();
}
module_form_alter被調用,我可以看到註冊屏幕上的新領域,但提交功能仍然沒有叫。我需要重寫默認的drupal註冊提交。
我已經有了下面的函數在我的主題的template.php
function templatename_theme() {
$items = array();
$items['user_login'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'portal_preprocess_user_login'
),
);
$items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-register-form',
'preprocess functions' => array(
'portal_preprocess_user_register_form'
),
);
$items['user_pass'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'portal') . '/templates',
'template' => 'user-pass',
'preprocess functions' => array(
'portal_preprocess_user_pass'
),
);
return $items;
}
用戶註冊,form.tpl.php
<div class="form-group">
<?php print drupal_render_children($form); ?>
</div>
和頁面 - 用戶 - register.tpl。 PHP與HTML
<div id="login-page">
<div class="container">
<div class="form-login" >
<h2 class="form-login-heading"><a href="<?php echo $home; ?>"><img src="<?php echo drupal_get_path('theme', 'portal') . '/images/logo.png'; ?>" width="100"></a><?php echo $createaccount; ?></h2>
<div class="login-wrap">
<?php
$elements = drupal_get_form("user_register_form");
$form = drupal_render($elements);
echo $form ?>
<?php if ($messages):?>
<div id="messages-console" class="clearfix">
<div class="grid_12">
<div class="mt-grid-fix">
<?php print $messages; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
這種方法很好,或者我應該改變這種方法,使我的自定義模塊f unctional?
請分享你已經嘗試到現在什麼。之後你開始研究它,如果你遇到問題,你可以發佈你的代碼。 – Panther 2015-03-30 17:52:12
@Panther感謝您的回覆!我編輯了qsn。 – wilNev 2015-03-30 18:42:37