SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | } | |
| 3 | ||
| 4 | /* We use jQuery to read the placeholder value and inject it to its field */ | |
| 5 | ||
| 6 | add_action('gform_enqueue_scripts',"my_gform_enqueue_scripts", 10, 2);
| |
| 7 | ||
| 8 | function my_gform_enqueue_scripts($form, $is_ajax=false){
| |
| 9 | global $is_IE; | |
| 10 | ||
| 11 | ?> | |
| 12 | <script> | |
| 13 | ||
| 14 | jQuery(function(){
| |
| 15 | <?php | |
| 16 | ||
| 17 | /* Go through each one of the form fields */ | |
| 18 | ||
| 19 | foreach($form['fields'] as $i=>$field){
| |
| 20 | ||
| 21 | /* Check if the field has an assigned placeholder */ | |
| 22 | ||
| 23 | if(isset($field['placeholder']) && !empty($field['placeholder']) && !$is_IE){
| |
| 24 | ||
| 25 | /* If a placeholder text exists, inject it as a new property to the field using jQuery */ | |
| 26 | ||
| 27 | ?> | |
| 28 | ||
| 29 | ||
| 30 | ||
| 31 | jQuery("#input_<?php echo $form['id']?>_<?php echo $field['id']?>").attr('placeholder',"<?php echo $field['placeholder']?>");
| |
| 32 | ||
| 33 | ||
| 34 | <?php | |
| 35 | } | |
| 36 | elseif($is_IE) { ?>
| |
| 37 | ||
| 38 | jQuery("#input_<?php echo $form['id']?>_<?php echo $field['id']?>").attr('value',"<?php echo $field['placeholder']?>");
| |
| 39 | ||
| 40 | ||
| 41 | <?php | |
| 42 | } | |
| 43 | } | |
| 44 | ?> | |
| 45 | }); | |
| 46 | </script> | |
| 47 | <?php | |
| 48 | } | |
| 49 | ?> |