addPlaceholders

The Gravity Forms Class Names to Placeholder Text addPlaceholders function.

Description

addPlaceholders(); 

Usage

  1. if ( !function_exists( 'addPlaceholders' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'gravity-forms-class-names-to-placeholder-text/gravity-forms-class-names-to-placeholder-text.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = addPlaceholders(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/gravity-forms-class-names-to-placeholder-text.php  
  1. function addPlaceholders() { 
  2. ?> 
  3. <script> 
  4. var gformNamesToPlaceHolders = function() { 
  5. function getGformName(s) { 
  6. if (s.indexOf("gfield_error") == -1) { 
  7. if (s.indexOf("gfield_contains_required") != -1) { 
  8. s = s.slice(10, s.lastIndexOf(" ")); 
  9. return s.slice(0, s.indexOf(" ")); 
  10. } else return s.slice(10, s.length); 
  11. } else { 
  12. if (s.indexOf("gfield_contains_required") != -1) return s.slice(21, s.lastIndexOf(" ")); 
  13. else return s.slice(21, s.length); 
  14. var a = document.getElementsByClassName("ginput_container"); 
  15. for (var i = 0; i < a.length; i++) a[i].firstChild.setAttribute("placeholder", getGformName(a[i].parentNode.getAttribute("class"))); 
  16. gformNamesToPlaceHolders(); 
  17. </script> 
  18. <?php