Created
September 13, 2013 16:43
-
-
Save jesgs/8835e2785e019938a0ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('gform_field_content', 'add_placeholder_attr', 10, 3); | |
/** | |
* Add a placeholder attribute to text inputs | |
* | |
* @param string $content | |
* @param array $field | |
* @param mixed $value | |
* | |
* @return string | |
*/ | |
function add_placeholder_attr($content, $field, $value) | |
{ | |
if ($field['type'] == 'text' || $field['type'] == 'email') { | |
$label = $field['label']; | |
$placeholder = "placeholder='{$label}' value='{$value}' "; | |
$content = str_replace("value='' ", $placeholder, $content); | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment