PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Placeholders issue

  1. cmccrone
    Member

    Im using the placeholders plugin listed below and I have found two problems.

    1 ) It erases/hides the text next to the radio, checkboxes etc
    2 ) When I created a paged form, it doesn't add the placeholders to the other pages (2nd, 3rd, etc). Just the first page of the form before you hit next.

    Anything wrong in this code that can fix those issues?

    PLUGIN: http://wordpress.org/extend/plugins/gravity-forms-auto-placeholders/

    function gfap_load_scripts() {
    	wp_enqueue_script('jquery');
    	wp_register_script('modernizr', 'http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js', array('jquery'));
    	wp_enqueue_script('modernizr');
    }
    add_action('wp_enqueue_scripts', 'gfap_load_scripts');
    
    function register_gfap_settings() {
    	$setting_vars = array(
    		'gfap_class',
    		);
    	foreach ( $setting_vars as $setting_var ){
    		register_setting( 'gfap_mystery', $setting_var );
    	}
    }
    add_action( 'admin_init', 'register_gfap_settings' );
    
    function gfap_menu() {
    	add_options_page( 'Gravity Forms Auto Placeholders Settings', 'Gravity Forms Auto Placeholders', 'manage_options', 'gfap_uid', 'gfap_options' );
    }
    
    function gfap_options() {
    	if ( !current_user_can( 'manage_options' ) )  {
    		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    	}
    	echo '<div class="wrap"><h2>Gravity Forms Auto Placeholders Settings</h2><form method="post" action="options.php">';
    	settings_fields('gfap_mystery');
    ?>
    
    <style>.wrap form td span{color:#888;} .wrap legend{font-size:13px; font-weight:bold; margin-left:-5px;} .wrap fieldset{margin:10px 0px; padding:15px; padding-top:0px; border:1px solid #ccc;}</style>
    <fieldset>
    	<legend>Convert labels to placeholders:</legend>
    	<table class="form-table">
    		<tr><td><input type="checkbox" name="gfap_class" value="1" <?php checked( '1', get_option( 'gfap_class' ) ); ?> /> Only on forms or form items with the class <b><i>gfap_placeholder</b></i> <span>- By default, leaving this unchecked will apply the effect to all Gravity Forms</span></td></tr>
    	</table>
    </fieldset>
    <p class="submit">
    <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
    </p>
    
    <?php
    	echo '</form></div>';
    }
    add_action( 'admin_menu', 'gfap_menu' );
    
    function gfap_script() { ?>
    
    <script>
    // Start allowance of jQuery to $ shortcut
    jQuery(document).ready(function($){
    
    	// Convert label to placeholder
    	<?php
    		$gfap_class_pc = get_option('gfap_class');
    		if ($gfap_class_pc) {
    			$gfap_class = 'gfap_placeholder';
    		}
    		else {
    			$gfap_class = 'gform_wrapper';
    		}
    	?>
    	$.each($('.<?php echo $gfap_class; ?> input, .<?php echo $gfap_class; ?> textarea'), function () {
    		var gfapId = this.id;
    		var gfapLabel = $('label[for=' + gfapId + ']');
    		$(gfapLabel).hide();
    		var gfapLabelValue = $(gfapLabel).text();
    		$(this).attr('placeholder',gfapLabelValue);
    	});
    
    	// Use modernizr to add placeholders for IE
    	if(!Modernizr.input.placeholder){$("input,textarea").each(function(){if($(this).val()=="" && $(this).attr("placeholder")!=""){$(this).val($(this).attr("placeholder"));$(this).focus(function(){if($(this).val()==$(this).attr("placeholder")) $(this).val("");});$(this).blur(function(){if($(this).val()=="") $(this).val($(this).attr("placeholder"));});}});}
    
    // Ends allowance of jQuery to $ shortcut
    });
    </script>
    
    <?php
    
    }
    
    add_action('wp_head', 'gfap_script');
    
    ?>

    Thanks to everyone that helps me out! Appreciate it!

    Posted 11 years ago on Friday August 24, 2012 | Permalink
  2. That placeholder plugin was not created by Gravity Forms and I'm unfamiliar with it. Please contact that plugin author for their support.

    http://wordpress.org/support/plugin/gravity-forms-auto-placeholders

    We'll leave this ticket open in case you need assistance with Gravity Forms and not this 3rd party plugin. Thanks.

    UPDATE: I see you started a topic there already. Please let us know what you find out.

    Posted 11 years ago on Friday August 24, 2012 | Permalink
  3. cmccrone
    Member

    Will do :)

    Posted 11 years ago on Friday August 24, 2012 | Permalink
  4. cmccrone
    Member

    @Chris I doubt the guy is going to respond any time soon. Whats is the most simple way to do this? I have some long application forms and they look AMAZING with placeholders vs titles above the input.

    I don't know where to begin.

    Thanks Chris

    Posted 11 years ago on Friday August 24, 2012 | Permalink
  5. If the jQuery is working on page 1 of the form but not subsequent pages, chances are you need to add the script to subsequent pages yourself. Please see this http://www.gravityhelp.com/documentation/page/Gform_page_loaded

    Posted 11 years ago on Saturday August 25, 2012 | Permalink