Created
September 2, 2014 05:05
-
-
Save DeveloperWil/5de4db2779428213d5ee to your computer and use it in GitHub Desktop.
Place Gravity Forms complex labels above fields
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 characters
| /** | |
| * 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; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment