Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
🇺🇦 |
This module is maintained by Ukrainian developers. Please consider supporting Ukraine in a fight for their freedom and safety of Europe. |
Overview
Module creates possibility to quickly add (by UI) placeholders to all textfields in any form on site.
Video tutorial made by Hans Riemenschneider — How to use the Form Placeholder module.
Features
-
Convert labels of single textfield or entire form to its placeholder.
- For old browsers not supporting HTML5 placeholder attribute uses jQuery Placeholder plugin by Mathias Bynens.
- Targeted textfields can be entered in textarea as CSS selectors.
- Convert form elements by classes.
form-placeholder-[include/exclude]-children
Include/exclude all children of given class.form-placeholder-[include/exclude]
Include/exclude single element.
- Integration with Form API by
#form_placeholder
attribute to convert elements.
// Convert all children in given form function MY_MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) { $form['#form_placeholder'] = TRUE; } // Convert single form element function MY_MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) { $form['my_element']['#form_placeholder'] = TRUE; }
Requirements
(Optional but recommended) Libraries module with jQuery Placeholder plugin if you want have fallback support for older browsers (i.e. IE 8 and older).
Installation and configuration
- Install Form Placeholder (form_placeholder) module as usual.
- Go to configuration page at "admin/config/user-interface/form-placeholder".
- Specify CSS selectors for textfields you want to add a placeholder.
- For older browsers not supporting "placeholder" attribute you have to:
- Install the Libraries module
- Download jQuery Placeholder plugin with one of following methods:
- Via Drush command:
drush download-placeholder-library
- Using Drush Make:
- Example usage of makefile can be found in form_placeholder.make.example
- Manually:
-
- Download jQuery Placeholder plugin from https://github.com/mathiasbynens/jquery-placeholder
- Rename downloaded directory to "jquery.placeholder" and place it under "sites/all/libraries" so the file "sites/all/libraries/jquery.placeholder/jquery.placeholder.js" will be accessible
Credits
- This project has been sponsored by e-direct.
- Idea by Justyna Kowalska.
Similar projects
Supporting organizations:
Initial development and support.
Project information
- Module categories: Site Structure, Developer Tools, Integrations
- 6,635 sites report using this module
- Created by rafenden on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
7.x-1.7
released 22 February 2018
Works with Drupal: 7.x
✓ Recommended by the project’s maintainer.
Development version: 7.x-1.x-dev updated 22 Feb 2018 at 22:13 UTC