samdark / yii2-cookbook

Yii 2.0 Community Cookbook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

form.yiiActiveForm('validate') cant validate without also submitting form

nsanden opened this issue · comments

Can't see how to do client side validation on a form without actually submitting the form.

with

form.data('yiiActiveForm').submitting = true;

it causes form to submit. can't seem to stop it.

without

form.data('yiiActiveForm').submitting = true;

it causes the form to not validate. even with:

form.yiiActiveForm('validate')

so you want to force the same validation that would be performed on form submit? This would rather be a feature request than an issue for this book because it is not possible as far as I see.
What is your use case for this?

Yes. Use case is this:
User fills in form, if validation is successful, instead of submitting form, I want to run some javascript to

  1. save form details in user session - probably an ajax request
  2. popup a bootstrap modal to let the user login via authclient authwidget
  3. after user logs in, i'll do stuff with session form details

please open this as a feature request on the repo then. it is currently not supported as far as I see.

roger that thanks cebe