简体   繁体   English

将占位符文本添加到Drupal 7 user_register_form

[英]Adding placeholder text to Drupal 7 user_register_form

So I can get the email and username field to work just fine. 因此,我可以使电子邮件和用户名字段正常工作。

here is the code 这是代码

if ( TRUE === in_array( $form_id, array('user_register_form'))) {
   $form['account']['name']['#attributes']['placeholder'] = t(' Username ');
   $form['account']['name']['#title_display'] = "invisible"; 
   $form['account']['mail']['#attributes']['placeholder'] = t(' Your Email ');
   $form['account']['mail']['#title_display'] = "invisible"; 

}

This works fine. 这很好。 But it seems the person who set this up is using custom field in the form because the it shows: 但似乎设置此设置的人正在使用表单中的自定义字段,因为它显示:

name="profile_installer_contractor[field_installer_first_name][und][0][value]" name =“ profile_installer_contractor [field_installer_first_name] [und] [0] [value]”

How can I get these fields to show the placeholder text? 如何获取这些字段以显示占位符文本? I have tried: 我努力了:

 $form['account']['field_installer_first_name'][und][0]['value']['#attributes']['placeholder'] = t(' First Name ');

but that doesn't seem to work. 但这似乎不起作用。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Thanks, Kevin 谢谢,凯文

nevermind I figured it out on my own. 没关系,我自己想通了。

$form[profile_installer_contractor]['field_installer_first_name'][und][0]['value']['#attributes']['placeholder'] = t(' First Name ');

this worked 这工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM