Drupal 如何从注册中删除密码和确认密码标题?
如何从注册中删除密码和确认密码标题? 我可以找到两者的名称是['pass[pass1]]&['pass[pass2]] 我在模板中写了下面的代码,我可以删除其他名称和电子邮件标签Drupal 如何从注册中删除密码和确认密码标题?,drupal,drupal-7,Drupal,Drupal 7,如何从注册中删除密码和确认密码标题? 我可以找到两者的名称是['pass[pass1]]&['pass[pass2]] 我在模板中写了下面的代码,我可以删除其他名称和电子邮件标签 enter code here function mysubtheme_form_alter(&$form, &$form_state, $form_id) { $form['account']['name']['#title']= t(''); $form['account']['name
enter code here
function mysubtheme_form_alter(&$form, &$form_state, $form_id) {
$form['account']['name']['#title']= t('');
$form['account']['name']['#description']= t('');
$form['account']['name']['#attributes'] = array('placeholder' => t('USER NAME'));
$form['account']['mail']['#title'] = t('');
$form['account']['mail']['#description'] = t('');
$form['account']['mail']['#attributes'] = array('placeholder' => t('MAIL'));
$form['account']['conf_mail']['#title']= t('');
$form['account']['conf_mail']['#description']= t('');
$form['account']['conf_mail']['#attributes'] = array('placeholder' => t('CONFIRM EMAIL'));
$form['account']['pass[pass1]']['#title'] = t('');
$form['account']['pass[pass1]']['#description'] = t('');
$form['account']['pass[pass1]']['#attributes'] = array('placeholder' => t('PASSWORD'));
$form['account']['pass[pass2]']['#title'] = t('');
$form['account']['pass[pass2]']['#description'] = t('');
$form['account']['pass[pass2]']['#attributes'] = array('placeholder' => t('CONFIRM PASSWORD'));
}
要覆盖
pass1
和pass2
的属性,您需要添加一个附加的#进程
处理程序,该处理程序在FAPI的表单(进程)密码(确认)之后运行,如下所示:
<?php
/**
* @file
* Allows modification of password fields in FAPI
*/
function register_alter_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_register_form':
// Here we need to provide an extra #process handler to allow us to modify
// the password element that FAPI expands.
$form['account']['pass']['#process'] = array('form_process_password_confirm', 'register_alter_password_confirm');
break;
}
}
/**
* Implementation of expand_password_confirm.
*/
function register_alter_password_confirm($element) {
$element['pass1']['#title'] = t("Password");
$element['pass2']['#title'] = t("Repeat password");
return $element;
}
?>
此代码段正在更改密码的名称并确认密码的标题。如果要删除它,只需添加t(“”)代码>。如果这不起作用,您还可以向其中添加特定的
,并显示显示:无代码>为它与CSS
希望有帮助
(注意:对于Drupal 6,将表单\u流程\u密码\u确认
更改为扩展\u密码\u确认
)要覆盖类属性,请使用以下属性作为密码
/**
* Implementation of expand_password_confirm.
*/
function register_alter_password_confirm($element) {
$element['pass1']['#attributes'] ['class'][] = 'inputxlarge';
$element['pass2']['#attributes'] ['class'][] = 'inputxlarge';
return $element;
}
@ SS153考虑通过点击上面答案的检查按钮来批准答案。我很高兴能帮上忙。对于任何想在D8中寻找解决方案的人,试试这个