OK so I have found a way for you to implement this today, first you will need to save the following file to your theme folder, the function below presumes you saved it to a folder named js inside your theme folder.
https://raw.github.com/harvesthq/chosen/v0.9.14/chosen/chosen.jquery.min.js
Next step is to copy the following function into your theme's functions file, it will check if the gravity forms chosen script has been enqueued for printing on a page and if so it will de-register it and then enqueue the updated script from your theme folder.
add_action('gform_enqueue_scripts','update_chosen',10,2);
function update_chosen($form)
{
if(wp_script_is('gforms_chosen',$list='queue')){
wp_deregister_script('gforms_chosen');
wp_enqueue_script('chosen-script',get_template_directory_uri().'/js/chosen.jquery.min.js',array('jquery'),'0.9.14',true);
}
return false;
}
Now while still in your functions.php file add the following to set the width to 100% rather than a fixed width, this will be outputted to all forms
add_action('gform_pre_render','set_chosen_width');
function set_chosen_width($form){
if(wp_script_is('chosen-script',$list='queue')){
?>
<script>
gform.addFilter('gform_chosen_options','set_chosen_options_js');
function set_chosen_options_js(options,element){
options.width = '100%';
return options;
}
</script>
<?php
}
return $form;
}
Next you will need to add some extra CSS to your theme's style.css file or wherever you are instructed to place custom CSS.
And that's it, go check your page, you may need to clear your cache.
Posted 11 years ago on Saturday May 25, 2013 |
Permalink