Skip to content

Instantly share code, notes, and snippets.

@wpsunshine
Last active March 28, 2024 17:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsunshine/f268bb9cb0f1abb938f8da2cf95b4bf7 to your computer and use it in GitHub Desktop.
Save wpsunshine/f268bb9cb0f1abb938f8da2cf95b4bf7 to your computer and use it in GitHub Desktop.
Gravity Forms use enhanced UI on select drop down for lists
<script>
// For standard forms
jQuery( document ).on( 'gform_post_render', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
// Forms that use multiple pages and ajax
jQuery( document ).on( 'gform_page_loaded', function( event, form_id, current_page ){
gformInitChosenFields( '#field_12_10 select', 'No results matched' ); // Change selector to #field_FORMID_FIELDID
});
</script>
// Add to functions.php - this enqueues the Chosen.js JavaScript library
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'gform_chosen' );
}, 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment