If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

Featured templates

Drupal 7.x. How to add/change contact form fields placeholders

This tutorial shows how to change or add contact form fields placeholders in Drupal 7.x.

Drupal 7.x. How to add/change contact form fields placeholders

In order to change contact form fields placeholders, you should perform the following:

  1. Find sites/all/themes/themeXXX/template.php file on the server via ftp or hosting cpanel file manager.

  2. Open the file with Sublime Text2 or later, Notepad++, Dreamweaver CS5.5+(Code mode only) or any php-editor.

  3. Check if you have the following code at the bottom of the file:

     
      function theme941_form_contact_site_form_alter( &$form, &$form_state, $form_id ) { 
      $form['name']['#attributes']['placeholder'] = t( "Name123:" ); 
      $form['name']['#title_display'] = 'invisible'; 
       
      $form['mail']['#attributes']['placeholder'] = t( "E-mail:" ); 
      $form['mail']['#title_display'] = 'invisible'; 
       
      $form['subject']['#attributes']['placeholder'] = t( "Subject:" ); 
      $form['subject']['#title_display'] = 'invisible'; 
       
      $form['message']['#attributes']['placeholder'] = t( "Message text:" ); 
      $form['message']['#title_display'] = 'invisible'; 
       
      unset ($form['copy']); 
      }  
    
  4. Change placeholders values:

    Drupal.-How-to-change-contact-form-fields-placeholders

  5. Save changes.

  6. Re-upload the edited file to the server.

  7. If you did not locate the code in the file, you will need to add this code to the bottom of the template.php file:

      
    function themeName_form_alter(&$form, &$form_state, $form_id) {
      if ($form_id == 'contact_site_form') {
      // Changing placeholder attributes values
      $form['name']['#attributes']['placeholder'] = t( 'Your name' );
      $form['mail']['#attributes']['placeholder'] = t( 'Your e-mail' );
      $form['subject']['#attributes']['placeholder'] = t( 'Your subject' );
      $form['message']['#attributes']['placeholder'] = t( 'Your message' );
      }
      }
    
  8. Save changes.

  9. Re-upload the edited file to the server.

Feel free to check the detailed video tutorial below:

Drupal 7.x. How to add/change contact form fields placeholders