Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * move field labels from below to above fields
- * add this to a simple plugin, or your theme's functions.php file
- *
- * @ref http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields
- * @ref http://pastebin.com/CfFeP4Ux
- *
- * @param array $form
- * @return array
- */
- function gf_script_move_labels_above($form) {
- ob_start();
- ?>
- (function($) {
- $(".ginput_container").has("input[type='email'],input[type='text'],input[type='password'],select,textarea").find("label").each(function() {
- var e = $(this), fielddesc = $("<div>").append(e.clone()).remove().html();
- e.siblings("input,select,textarea").before(fielddesc);
- e.remove();
- });
- })(jQuery);
- <?php
- $script = ob_get_clean();
- GFFormDisplay::add_init_script($form['id'], 'gf_labels_above', GFFormDisplay::ON_PAGE_RENDER, $script);
- return $form;
- }
- add_filter('gform_register_init_scripts', 'gf_script_move_labels_above');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement