Created
May 12, 2014 03:39
-
-
Save webaware/24e1bacb47b76a6aee7f to your computer and use it in GitHub Desktop.
Revisions
-
webaware revised this gist
May 12, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php /* Plugin Name: Gravity Forms Fields Above Plugin URI: https://gist.github.com/webaware/24e1bacb47b76a6aee7f Description: move field labels from below to above fields in compound fields (e.g. Address, Name) Version: 1 Author: WebAware -
webaware created this gist
May 12, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ <?php /* Plugin Name: Gravity Forms Fields Above Plugin URI: Description: move field labels from below to above fields in compound fields (e.g. Address, Name) Version: 1 Author: WebAware Author URI: http://webaware.com.au/ @link http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields @link http://pastebin.com/CfFeP4Ux @link http://pastebin.com/WCuDc0Eh */ /** * make sure jQuery is loaded */ add_action('wp_enqueue_scripts', function() { wp_enqueue_script('jquery'); }); /** * register custom form scripts * @param array $form * @return array */ add_filter('gform_register_init_scripts', function($form) { ob_start(); ?> jQuery(".ginput_container").has("input[type='email'],input[type='text'],input[type='password'],select,textarea").find("label").each(function() { var e = jQuery(this), fielddesc = jQuery("<div>").append(e.clone()).remove().html(); e.siblings("input,select,textarea").before(fielddesc); e.remove(); }); <?php $script = ob_get_clean(); GFFormDisplay::add_init_script($form['id'], 'gravity-forms-fields-above', GFFormDisplay::ON_PAGE_RENDER, $script); return $form; });