You are here

README.txt in Form Placeholder 7

Installation
------------------
1. Install Form Placeholder (form_placeholder) module as usual.
2. Go to configuration page at "admin/config/user-interface/form-placeholder".
3. Specify CSS selectors for textfields you want to add a placeholder.
4. For older browsers not supporting "placeholder" attribute you have to:
  1. Install the Libraries module
  2. 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


Usage
------------------
// 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;
}

It's also possible to convert form elements by classes:
1. form-placeholder-[include/exclude]-children
   Include/exclude all children of given class.
2. form-placeholder-[include/exclude]
   Include/exclude single element.

File

README.txt
View source
  1. Installation
  2. ------------------
  3. 1. Install Form Placeholder (form_placeholder) module as usual.
  4. 2. Go to configuration page at "admin/config/user-interface/form-placeholder".
  5. 3. Specify CSS selectors for textfields you want to add a placeholder.
  6. 4. For older browsers not supporting "placeholder" attribute you have to:
  7. 1. Install the Libraries module
  8. 2. Download jQuery Placeholder plugin with one of following methods:
  9. Via Drush command:
  10. drush download-placeholder-library
  11. Using Drush Make:
  12. Example usage of makefile can be found in form_placeholder.make.example
  13. Manually:
  14. Download jQuery Placeholder plugin from https://github.com/mathiasbynens/jquery-placeholder
  15. Rename downloaded directory to "jquery.placeholder" and place it under "sites/all/libraries"
  16. so the file "sites/all/libraries/jquery.placeholder/jquery.placeholder.js" will be accessible
  17. Usage
  18. ------------------
  19. // Convert all children in given form
  20. function MY_MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
  21. $form['#form_placeholder'] = TRUE;
  22. }
  23. // Convert single form element
  24. function MY_MODULE_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
  25. $form['my_element']['#form_placeholder'] = TRUE;
  26. }
  27. It's also possible to convert form elements by classes:
  28. 1. form-placeholder-[include/exclude]-children
  29. Include/exclude all children of given class.
  30. 2. form-placeholder-[include/exclude]
  31. Include/exclude single element.