0
我想定製我的用戶配置文件編輯頁面。編輯路徑是:XXX /用戶/ 2 /編輯 1.我templage文件:drupal 7 cusomized用戶配置文件模板無法保存更改
function MYTHEME_theme() {
'user_profile_form' => array(
'arguments' => array('form' => NULL),
'render element' => 'form',
'template' => 'user-profile-form',
'path' => drupal_get_path('theme', 'bootstrap_subtheme').'/templates',
),
}
function MYTHEME_preprocess_user_profile_form(&$vars) {
drupal_set_title('Account settings');
unset($vars['form']['account']['mail']['#description']);
$vars['form']['account']['mail']['#title'] = t('Email:');
unset($vars['form']['picture']['#title']);
unset($vars['form']['picture']['picture_delete']);
$vars['form']['picture']['picture_upload']['#title'] = t('Upload new photo:');
$vars['form']['picture']['picture_upload']['#attributes']['class'][] = 'form-text';
unset($vars['form']['picture']['picture_upload']['#description']);
unset($vars['form']['account']['current_pass']['#description']);
unset($vars['form']['account']['pass']['#description']);
unset($vars['form']['account']['pass2']['#description']);
unset($vars['form']['field_birthday']['und']['#prefix']);
unset($vars['form']['field_birthday']['und']['#suffix']);
unset($vars['form']['field_birthday']['und']['#title']);
$vars['form']['account']['pass']['pass1']['#title'] = t('New password:');
$vars['form']['account']['pass']['pass2']['#title'] = t('Re-enter new password:');
$vars['form']['actions']['submit']['#value'] = t('Save changes');
$vars['form']['actions']['submit']['#attributes']['class'][] = 'btn';
$vars['form']['actions']['submit']['#attributes']['class'][] = 'btn-purple';
$vars['form']['account']['mail']['#size']=20;
}
我的用戶配置文件,form.tpl.php文件
:
<div class="row-fluid">
<div class="span1 offset2">Gender:</div>
<div class="span4 offset1"><?php print render($form['field_gender']);?></div>
</div>
<div class="row-fluid">
<div class="span1 offset2">Password:</div>
<div class="span4 offset1"><?php print render($form['account']['pass']);?></div>
</div>
<?php print render($form['actions']);?>
現在的形式但是,當我更改密碼時,沒有錯誤,但我無法用新密碼登錄。我再次測試它,似乎只有管理員可以更改它,認證用戶不能更改自己的密碼。
感謝,這種方法效果很好。但渲染(drupal_get_form('module_edit_account_form',$ user));不起作用。我認爲我們不能將用戶對象傳遞給這個函數。我已將用戶對象移至提交功能。 – user3210341
是的,在我自己的代碼中,我將自定義用戶數據傳遞給drupal_get_form函數..所以這只是一個例子.. – Hardy