HI there, I need to add an extra hook to the functions.php but every time I click save the screen goes blank.
Here’s the code I need to add:
<?php
/**
* If you need to make some of the GravityView search fields required before search is submited
* – add as many lines as you need to define which fields are required
* e.g. -> jQuery(‘#gv_search_XYZZ’).prop(‘required’, true );
*
* Add this gist to your theme functions.php
*
*/
add_action(‘gravityview_after’, ‘my_theme_make_search_fields_required’ );
function my_theme_make_search_fields_required() {
?>
<script>
//define here the search fields that are required
jQuery(‘#gv_search_2247’).prop(‘required’, true );
// validation magic
jQuery(‘form.gv-widget-search’).submit( function(e) {
e.stopPropagation();
var isValid = true;
jQuery(‘.gv-widget-search input:required’).each( function(){
if( jQuery(this).val() === ” ) {
isValid = false;
}
});
return isValid;
});
</script>
<?php
}
What I’m doing wrong?
Please let me know how to fix it.
Hey Jorge!
Your website doesn’t load on my end, have you checked your PHP error log for some clue?
Best regards,
Josue
Hi Josue, now it loads correctly. Can you check again please.
Hi!
Please re-check the URL:
http://www.downforeveryoneorjustme.com/http://www.burorento.com.mx/servicio
Best regards,
Josue
Hi!
Try putting the code without the “<?php”. Also i’d recommend using this plugin to store custom functions like that, separated from the theme source.
Best regards,
Josue