FuelPHP Bin
var prepare_all_forms_for_csrf = function() { //collect all form with method="POST" var $all_forms = $('form[method="POST"]'); console.groupCollapsed('prepare_all_forms_for_csrf()...') //check if any found... if( $all_forms.length ) { //iterate through each of them... $all_forms.each(function() { var $each_form = $(this); //check if there are any hidden fields (a.k.a dirty check for csrf-token fields...) if ($each_form.find('input[type="hidden"]').length) { //call fiel_set_csrf_token() fot the current form element... fuel_set_csrf_token(this); console.info('csrf-toekn updated for : ', $each_form ); } }) } else { //debug purpose... console.warn('No forms to prepare...'); } console.groupEnd('prepare_all_forms_for_csrf()...'); }