简体   繁体   中英

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]"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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