READ ME FIRST

Once FAPI uses HTML5 to render elements, this module can be replaced by the "placeholder" attribute available as part of the HTML5 spec. You can update the FAPI to use the "placeholder" attribute right now by using elements module. This means that this module is only useful if you are concerned about older browsers that do not support "placeholder".

*If you are upgrading from 7.x-1.0-rc1 you will need to upgrade the placeholder library. See the README.txt file for details.

General Information

This project adds an extra FAPI attribute called '#placeholder' to textfield field elements. Often textfields should have some text in them like "Enter your text here" until the user clicks on (or tabs to) the element in question. At that point, the text should disappear and the user can enter his or her desired input.

Take a look at the "Search Drupal.org" text in the search box at the top of this page to see what I'm talking about :)

Example

<?php
  $form
['name'] => array(
   
'#type' => 'textfield',
   
'#required' => TRUE,
   
'#placeholder' => t('Enter your name here'),
  );
?>

Project Information

Downloads