- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
Drupal 7.x. How to add/change contact form fields placeholders
April 3, 2015
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:
-
Find sites/all/themes/themeXXX/template.php file on the server via ftp or hosting cpanel file manager.
-
Open the file with Sublime Text2 or later, Notepad++, Dreamweaver CS5.5+(Code mode only) or any php-editor.
-
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']); }
-
Change placeholders values:
-
Save changes.
-
Re-upload the edited file to the server.
-
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' ); } }
-
Save changes.
-
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