Hi guys, I need your advice.
I’m using ajax editing widely, and sometimes the code for submit is sophisticated, so I’ve created a couple of hooks for this.
Right now I bind them to ActiveForm’s beforeSubmit, like this:
<?php $form = ActiveForm::begin([
'validateOnType' => true,
'beforeSubmit' => 'process'
]); ?>
<script>
function process($form) {
console.log('submitting the form');
// $.ajax(...);
return false;
}
</script>
Very convenient, because it happens after client-side validation.
But here’s the catch: if no fields are subject to validation, beforeSubmit is not fired (actually, no ActiveForm js code is created at all).
What’s the workaround for this?